Computing.Net > Forums > Unix > simple script help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

simple script help

Reply to Message Icon

Name: gpatel
Date: May 5, 2005 at 08:49:52 Pacific
OS: UNIX
CPU/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



Sponsored Link
Ads by Google

Response Number 1
Name: willtx56
Date: May 5, 2005 at 14:29:47 Pacific
Reply:

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


0

Response Number 2
Name: cdac1000
Date: May 6, 2005 at 07:13:47 Pacific
Reply:

#!/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?


0

Response Number 3
Name: gpatel
Date: May 6, 2005 at 13:27:43 Pacific
Reply:

thanks a lot cdac..

thanks,
Gaurav


0

Response Number 4
Name: Dlonra
Date: May 6, 2005 at 18:37:27 Pacific
Reply:


needs to be
programName $element > "${element}NEW.txt"


0

Response Number 5
Name: gpatel
Date: May 7, 2005 at 10:45:48 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: hismail
Date: May 25, 2005 at 06:54:18 Pacific
Reply:

Try this:
#!/bin/ksh
for f in $(find dirname -type f -name filename);do
cd $(dirname $f);programName $element > "${element}NEW.txt;cd -;done


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: simple script help

simple script to run every1/2 hr www.computing.net/answers/unix/simple-script-to-run-every12-hr/4595.html

Simple script to copy files www.computing.net/answers/unix/simple-script-to-copy-files/4521.html

Script help, Im having a brain fart www.computing.net/answers/unix/script-help-im-having-a-brain-fart/7814.html