![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Comparison List of commands | f_amshan | UNIX for Advanced & Expert Users | 1 | 08-19-2006 06:08 AM |
| List of Commands | ArabOracle.com | SUN Solaris | 2 | 10-12-2005 01:03 AM |
| .sh_history contains the list of past commands | yls177 | UNIX for Dummies Questions & Answers | 1 | 12-03-2002 03:15 AM |
| A Thorough List of FreeBSD commands?!? | Kyser_Soze | UNIX for Dummies Questions & Answers | 1 | 10-20-2001 10:18 AM |
| List of Commands for Unix Please | ShdwMaster | UNIX for Dummies Questions & Answers | 5 | 03-08-2001 06:28 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
list files commands
hi all scripting gurus,
need some guide and advise from you. i'm trying to list all the files in the year 2004 and the file format is something like this: 11176MZ00004JV900004JVB00004JVCcDBU20041206.txt try to use the symbol ^ but somehow it does not help. i try this as well: ls -ltr | grep 200401 | more and it does shows the files listed in 2004 but also in 2005 and 2006. any way i can refine this search? can anyone help? many thanks. wee |
| Forum Sponsor | ||
|
|
|
|||
|
If there are files from 2005 and 2006 which coincidentally contain 200401 in their file name then you need to make the regular expression more exact. If the date is always just before a final .txt extension then grep 2004....\.txt$ might work better. (Just a dot means "any character" in a regular expression.)
|
|
|||
|
Quote:
thanks for the guide. tried the command but getting this result: spids111% ls -ltr |grep *2004....\.txt$* | more No match spids111% somewhere gone wrong in my command line? thanks again! wee |
|
|||
|
Quote:
wee |
|
|||
|
apologies...one more question.
if i want to remove the files in 2004 what is the next command i need to put in? using rm command? like this: spids111% ls -ltr | grep 2004....\.txt$ | rm * ? |
|
|||
|
rm doesn't read standard input, it expects the files to remove on its command line. Use xargs or backticks.
Code:
rm `ls -ltr | grep 2004....\.txt$` Code:
ls -ltr | grep 2004....\.txt$ | xargs rm |