![]() |
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 |
| message in make files | murad.jaber | SUN Solaris | 3 | 01-17-2008 04:44 AM |
| How can I make dos2unix in hp without renaming files? | umen | UNIX for Dummies Questions & Answers | 2 | 01-14-2008 03:16 AM |
| iso files to make bootable dvd image | bdsffl | SUN Solaris | 0 | 11-18-2006 02:25 AM |
| Need to make disk device files match | mvizza | HP-UX | 0 | 06-01-2006 04:03 PM |
| Make files | Dan Rooney | Shell Programming and Scripting | 2 | 04-23-2004 09:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
make use of the name of files
there are a number of files under the folder myfolder:
myfolder: a_file_1 a_file_2 a_file_3 ... b_file_1 b_file_2 b_file_3 ... .... how can I write a script to do following: if the name of the file starts with a, append the content of this file to file Final; if the name of the file starts with b and the third field is greater than 2, append the content of this file to file Final for twice; else, add a line " ================ ". thanks! |
|
||||
|
Quote:
|
|
||||
|
Quote:
find ./files/* | while read file do if [ the name of the file start with "S" ]? then run ./a script ? elif [ the name of the file start with a number ]? then run ./b script? fi done ############## my problem is the place marked with "?" |
|
|||||
|
here's something to start with - good luck:
Code:
#!/bin/ksh
find . -type f | while read path
do
file=$(basename "${path}")
if [[ "${file}" == @(S*) ]]; then
echo "[$path] run ./a script ?"
elif [[ "${file}" == @([0-9]*) ]]; then
echo "[$path] run ./b script ?"
fi
done
Last edited by vgersh99; 12-13-2006 at 04:15 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|