Sponsored Content
Top Forums Shell Programming and Scripting sort file text by date as a "ls -t" Post 302358715 by protocomm on Sunday 4th of October 2009 09:57:48 AM
Old 10-04-2009
I list files on server ftp and, it gives me a list of file in alphabetic order.
I want this list of file in order like "ls -t", the niewer in first and the older last.

INPUT:

Code:
drwxr-x---  2 ftp_mont System            0 Sep 30 09:16 .
drwxr-x---  2 ftp_mont System            0 Jul 15  2009 ..
-rwxr-x---  1 ftp_mont System    250324761 Sep 27 15:47 Dossier_secheresse-H264-1.mov
-rwxr-x---  1 ftp_mont System    343998791 Sep 30 09:20 manif laitiers-H264.mov
-rwxr-x---  1 ftp_mont System    169097455 Sep 27 15:55 Mende_Mende-H264.mov
-rwxr-x---  1 ftp_mont System     12063097 Sep 27 15:32 Mende_Mende_ITW.mov

OUTPUT:

Code:
-rwxr-x---  1 ftp_mont System    343998791 Sep 30 09:20 manif laitiers-H264.mov
-rwxr-x---  1 ftp_mont System    169097455 Sep 27 15:55 Mende_Mende-H264.mov
-rwxr-x---  1 ftp_mont System    250324761 Sep 27 15:47 Dossier_secheresse-H264-1.mov
-rwxr-x---  1 ftp_mont System     12063097 Sep 27 15:32 Mende_Mende_ITW.mov

I want to do this because i get file by mirroring with wget and wget have a problem with the files with accent...
I thank to rename the file downloaded by wget with the list of file on server then i have 1 file text where have the file in order "by time"

Code:
let i=0;for file in /Users/macbook/oberon/*;do echo "$file";let i=i+1;var="$(cat $temp/oberon_trie.txt | sed 's/ *$//g' | sed -n "$i"p)";mv "$file" "/Users/macbook/oberon/$var";done


Last edited by protocomm; 10-04-2009 at 11:03 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

add seconds to: date"|"time"|"HHMMSS

Hey all, I have a shell that invokes a AWK. In this AWK i want invoke a function that receives 3 parameters: date: 20080831 time: 235901 duration: 00023 that function receive this 3 parameters and sum to this value two more seconds: 2008083123590100025 Remember that in case that... (3 Replies)
Discussion started by: anaconga
3 Replies

2. Solaris

"mail" command sort by date

Hello experts, I am using SunFire T200. When I start reading the mail with "mail" command it comes older mail first. From MAILER-DAEMON Sat Mar 28 06:02:48 2009 Return-Path: <MAILER-DAEMON@emarn1> Received: from localhost (localhost) .... .... I want to see the most recent mail... (1 Reply)
Discussion started by: thepurple
1 Replies

3. AIX

xx=`date +"%a %b %d"`;rsh xxx grep "^$XX" zzz ?

AIX 4.2 I am trying to do an rsh grep to search for date records inside server logs by doing this : xx=`date +"%a %b %d"` rsh xxx grep "^$XX" zzz gives : grep: 0652-033 Cannot open Jun. grep: 0652-033 Cannot open 11. But if I do : xx=`date +"%a %b %d"` grep "^$XX" zzz it works... (2 Replies)
Discussion started by: Browser_ice
2 Replies

4. Shell Programming and Scripting

Meaning of "b" modifier in "sort" command

I need to sort the following file by the rhdiskpower devices in the last column: Total_MB Free_MB OS_MB Name Failgroup Library Label UDID Product Redund Path 1024 851 1024 OCRVOT1_0000 OCRVOT1_0000 System UNKNOWN ... (3 Replies)
Discussion started by: wjssj
3 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

sort text having delimiter with "|" (pipe)

i am having text file below NARGU S S 12358 SALES REP |22| Acccount/s RAJU R B 64253 SALES REP |12| Acccount/s RUKMAN S 32588 SALES REP |10| Acccount/s NARGUND S S 12356... (3 Replies)
Discussion started by: suryanarayana
3 Replies

7. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

8. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

9. UNIX for Beginners Questions & Answers

Extract delta records using with "comm" and "sort" commands combination

Hi All, I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file. comm -3 < sort file_old < sort file_new > new_file I am getting the below error: -ksh: sort: cannot open But if I do... (7 Replies)
Discussion started by: njny
7 Replies

10. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
ftpls(1)						      General Commands Manual							  ftpls(1)

       ftpls - generate a ftp directory listing

SYNOPSIS
ftpls ftp://host[:port]/directory or ftpls host[:post] /directory DESCRIPTION
ftpls generates a listing of files and directories in a FTP directory. ftpls by default prints a human readable ascii output, but may also create HTML and machine parsable output. OPTIONS
Login options -u, --user=NAME Use NAME to login on the ftp server. Note that this option overrides an user name given in an URL. The default is `anonymous'. Use an empty name to force to not log in. -p, --pass=PASSWORD Use PASS as password to login on the ftp server. Note that this option overrides a password given in an URL. The default is `anonymous@invalid.example'. Use an empty password to enforce not sending any password. --account=ACCOUNT Send ACCOUNT as the account name using the ACCT ftp command if the ftp servers asks for one. ACCOUNT in ftp speak is some kind of sub account in some other terminologies. If you don't understand what it means you have a good chance to never need this option anyway. If you think you need it please try the -u option first. --tries=NUMBER Number of tries to connect and log in. The default is 1, meaning that ftpls will give up after the first error. --login-sleep=NUMBER ftpls will sleep for NUMBER seconds after a try to connect or login has failed. The default is 5, a zero is treated as one, and abuse (especially together with --tries) is likely to annoy the server administrator. This option was added in version 0.4.5. Output mode options -h, --html Create HTML index containing all files together with modification time and size. Note: The links in this index will contain username and password if you include them into an URL given to ftpls on the command line (either as argument or through the --urlprefix option). They will not be included otherwise, for security and privacy reasons. -m, --machine Create machine parsable output. -t, --title=TEXT Title text to use on the HTML output. -U, --urlprefix=URL URL-Prefix to use in listings. If this option is not given then an URL given on the command line will be used instead, and if this has not been given an URL will be created from host, port and directory given on the command line. --print-dir Print the name of a sub directory before printing it's content. Do not print the name of the top level directory of the listing. Use this option together with --raw. Do not use it together with --html. SORTING -a, --alpha sort alphabetical. -z, --omega sort reverse alphabetical. -n, --newest sort youngest first. -o, --oldest sort oldest first. -s, --shortest sort shortest first. -l, --longest sort longest first. Other options --ascii-listings Do directory listings in ASCII mode instead of binary mode. Use this option if the FTP server is unable to correctly list directories in binary mode, for example, if you see a message like this: ftpls: failed to read directory listing: protocol error This option was added in version 0.5.2. -L, --list-options=OPTS Add OPTS to LIST command. This allows to pass arbitrary options to the FTP servers LIST command. Note that ftpls does not cope well with recursive directory listings. --interactive ftpls will read the directories to be listed from the standard input. Any remote directory given on the command line will be ignored. Each directory listing is terminated by a END-OF-LISTING line. Do not use this together with the --html option. This option was added in version 0.3.6. -R, --recursive Do a recursive directory listing by first printing one directory, including sub directory names, and then traversing into sub directories. --raw Output directory listings in the original format and sort order. -T, --timeout=SECONDS Timeout to use for network read/write and connect operations. The default is 30 seconds and is usually sufficient. This option was added in version 0.3.8. --force-select Do not use the poll() system call even if it's available, but use select(). This allows ftpls to be used together with the runsocks program from the socks5 reference implementation. Please note that you'll need a directly reachable name server anyway, as the DNS library in use does not support SOCKS (you can always use IP addresses). This option was added in version 0.3.8. --max-depth Descend at most LEVEL directories deep. 0 means do not enter sub directories at all, 1 means enter sub-directories, but not their sub-directories, and so on. This option enables the --recursive option, too. The default is 2^32-1, meaning enter all. This option was added in version 0.5.2. EXAMPLES
Generate a HTML index page ftpls --html --title "CVS tree index by date" --urlprefix ftp://ftp.ohse.de/uwe/cvs-trees/ --newest ftp://serak.ohse.de/uwe/cvs-trees > SOMEWHERE/cvs-trees/index-by-date.html AUTHOR
Uwe Ohse, uwe@ohse.de SEE ALSO
ftpcopy(1). The homepage may be more up-to-date, see http://www.ohse.de/uwe/ftpcopy.html. ftpcopy 0.5.2 ftpls(1)
All times are GMT -4. The time now is 09:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy