simple script help
|
Original Message
|
Name: gpatel
Date: May 5, 2005 at 08:49:52 Pacific
Subject: simple script helpOS: UNIXCPU/Ram: 512 |
Comment: This is very simple script. I am not a guru at unix just start using it so need some help from you gurus. This is my Problem I have this folder w/ lots of file. now lets say i have a file name MyFile.txt I have a program to run this file so this is how i run it program MyFile > MyFilenew.txt I just wanted to automatically grab the file w/ .txt extension and run it by just typing program this is how i set up my script # !/bin/csh -f cd /myDir program MyFile > Myfilenew.txt ----- i dont want to go in the this script and change MyFile all the time. this My File changes everytime i do something new. but extension stay the same as .txt can some help w/ this. thanks a lot Gaurav thanks, Gaurav
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: willtx56
Date: May 5, 2005 at 14:29:47 Pacific
|
Reply: (edit)This is where is started in Unix commands https://portal.informatics.scitech.sussex.ac.uk/support/sitedocuments/unix.aspx Biostar NF3250GB 6800GT BFG Seagate 200 gig LanBoy/550W Antec Audigy 2 XP Professional
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: cdac1000
Date: May 6, 2005 at 07:13:47 Pacific
|
Reply: (edit)#!/bin/ksh cd /directory_name for element in `ls *.txt` do programName $element > "$elementNEW.txt" done what this will do is, generate an a list of entries of all files containg .txt extension, and then process them with you program, and will put the output in file, using the fileprocessedNEW.txt convention. Is this what ur looking for?
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: gpatel
Date: May 7, 2005 at 10:45:48 Pacific
|
Reply: (edit)thank you very much guys.. is there any way i dont have use cd what i am saying.. there are 16 files under 3 folders. so i have to go and change and do cd and put the right path name. In details lets say i have File1 File2 File3 in File1 i have 4 folders in File2 i have 4 Folders and same with File3 now, to use this program i have to go and say cd to File1 then cd to File2 is there any way to automate this and program will go thru all the folders (File1 , File2 and File3) again Thank you very much for you help thanks, Gaurav
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: hismail
Date: May 25, 2005 at 06:54:18 Pacific
|
Reply: (edit)Try this: #!/bin/ksh for f in $(find dirname -type f -name filename);do cd $(dirname $f);programName $element > "${element}NEW.txt;cd -;done
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: