Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I want to excute a shell script by passing a CSV file as argument, where the file name will be based on the file that is been placed in a particular directory.Ex: cleaner.sh GSM20050609.csv
the argument file will be the one in the directory. How to read the file name and pass it.
Thanks
SivaHi,
I'm trying to replace a column in a comma seperated file with a column in another file using sed/awk. Can anyone help me.Thanks
Siva

if [ $# -ne 1 ] ; then
echo '\nUsage: cleaner.sh <filename>\n'
exit 1
fidir=/home/particular
fname=$1if [ ! -r $dir/$fname ] ; then
echo "$fname does not exist in $dir"
echo " or I have no read access"
exit 1
fiecho "Now processing $dir/$1 ..."

Jim,
Think my question is not clear, let me put it in other way..
In /home/files I have 2 files GMS.txt and AMS.txt
I've my script /home/scripts/cleaner.shNow I want to pass all the files in /home/files to cleaner.sh as argument one by one.
like cleaner.sh GMS.txt
cleaner.sh AMS.txt
I want a script which will get files from /home/files directory and pass it to cleaner.sh as argument.
Can you help me.Thanks
SivaHi,
I'm trying to replace a column in a comma seperated file with a column in another file using sed/awk. Can anyone help me.Thanks
Siva

Sure, here's a couple of different ways:
find /home/files -exec c /home/scripts/cleaner.sh {} \;
orfor fname in $(ls /home/files)
do
/home/scripts/cleaner.sh $fname
done
On the find command approach, you can add additional filters to the find command, such as:regular files only (ignore directories etc)
modify date filter
file size filter
file ownership
etc

Jim,
Yeah....it works great.Thanks
SivaHi,
I'm trying to replace a column in a comma seperated file with a column in another file using sed/awk. Can anyone help me.Thanks
Siva

![]() |
Character substitution
|
UNIX server help
|

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