![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| part of a filename | flame_eagle | Shell Programming and Scripting | 8 | 02-28-2008 11:18 AM |
| Report of duplicate files based on part of the filename | sudheshnaiyer | UNIX for Dummies Questions & Answers | 1 | 12-18-2007 04:31 PM |
| read a part of information from txt and put into the script | happyv | Shell Programming and Scripting | 18 | 10-27-2006 10:46 AM |
| Wanted to eliminate numeric part from a filename | Sona | UNIX for Dummies Questions & Answers | 8 | 07-20-2006 02:49 PM |
| list only identical filename | HAA | Shell Programming and Scripting | 6 | 05-17-2006 11:04 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
read a part of filename from the list in the script
how can i read a part of filename from the list in the script?
all file in directory...will start with "CDBACKUPFILE" then the name is stored in list.txt such as JOHN,MARRY,PETER. After this, is seq number. CDBACKUPFILEJOHN00001 CDBACKUPFILEMARRY00004 CDBACKUPFILEPETER00003 I will use: ls -l CDBACKUPFILE*.archived to list out file. can I write a script to read a file "list.txt" and the script can put JOHN, MARRY, PETER, etc into the statement? |
|
||||
|
Hi
You could first discard the CDBACKUPFILE string by using a substring command based on the length of this first parameter. Then use a filter to remove any number from your string, or alternatively a substring command if your seq number has a fixed length. I don't give you the code as I don't have the time to test it I just hope this will indicate you how to do the job. |
|
||||
|
Quote:
ls -l|while read line do #the followng will first cut out the CDBACKUPFILE, then using awk, i'll specify #0 as the field delimiter and print out the first field, which will be the name cut -c 1-12|awk -F"0" '{print $1}'>file.txt done |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|