Sortowanie pliku.

 
Napisz nowy tematOdpowiedz do tematu    Forum programistyczne Programmers Zone Strona Główna -> Python, Perl, Bash
Autor Wiadomość
climbwave
~user




Dołączył: 11 Mar 2008
Posty: 41


PostWysłany: 14-05-09 16:02 Zacytuj zaznaczone Odpowiedz z cytatem

---------- 10:58 13.05.2009 ----------

Witam,

Napisalem skrypt ktory:
- pobiera zawartosc pliku z jednego katalogu w komputerze A i wyswietla w komputerze B
- FTP zaznaczony plik z kompa A do kompa B'

Problem w tym, ze chcialbym aby wylistowana zawartosc w terminalu byla uporzadkowana wedlug daty. Jak to zrobic i co zmienic.

Z gory dzieki za podowiedz.

Pozdrawiam,
c

Cytat:


#!/bin/sh -f

#############################################################
#
#
#############################################################
#
#
#
#Connecting to a Spectra
HOST='192.168.1.1'
USER='user'
PASSWD='user'
SPECTRA_DIR='/a/b/'
SPRINT_DIR='/c/d/e'

#Removing old list from last listining
#Removing temporary files from last listening
rm dirlisting.txt

#Creating a new empty files.
touch dirlisting.txt

#Setting local directory for Sprint.
cd $SPRINT_DIR

#Ftp to Spectra 1 computer to get file listining
ftp -n -i $HOST <<end_of_script
quote USER $USER
quote PASS $PASSWD
cd $SPECTRA_DIR

#The file dirlisting.txt contains of a files in the Spectra 1 P2/94 directory
ls *.* dirlisting.txt
bye
end_of_script

#Setting local directory
cd $SPRINT_DIR

#Listining files from older to newer.
#sort dirlisting.txt

#Selecting a files
cat dirlisting.txt | sort -t - -k1

echo -n "Select from the file above and past after arrow ==> "
read FILE

#Deleting the temporary file drilisting.txt
rm dirlisting.txt

#Connect to Spectra 1 directory to get the P2 files
ftp -n -i $HOST <<end_of_2_script
quote USER $USER
quote PASS $PASSWD
bin
cd $SPECTRA_DIR

#Prininting hash symbols to show progress on of the FTP transfer
#hash
get $FILE
bye
end_of_2_script

echo "------------------------------------------------------"
echo "==>> Check of the first and last shotpoint recorded corectly excl.gif!<<=="
echo " "
grep "E1000" $FILE > shots_check
head -n 1 shots_check
tail -1 shots_check
echo "------------------------------------------------------"


---------- 21:02 14.05.2009 ----------

Rozwiązanie to :

Kod:


cat dirlist.txt | sort --key=1.12,1.14



_________________
K12S
Powrót do góry
Zobacz profil autora Wyślij prywatną wiadomość Odwiedź stronę autora Numer GG
Wyświetl posty z ostatnich:   
Napisz nowy tematOdpowiedz do tematu    Forum programistyczne Programmers Zone Strona Główna -> Python, Perl, Bash Wszystkie czasy w strefie EET (Europa)
Strona 1 z 1

 
Skocz do:  
Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach

Mapa
Powered by phpBB © 2001, 2005 phpBB Group

 Polecane strony