Parametrization Help


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Parametrization Help
# 1  
Old 07-14-2013
Parametrization Help

Hi,

Need help in Parametrize the file name and passing the file name as a prompt to the script.

Currently I am using a filename inside my script has below
Code:
export input_filename=/path/SRC_FILE_NAME.txt

I want to parametrize the filename and pass SRC_FILE_NAME.txt to the shell script as below to make the filename as dynamic

Code:
sh shellsctipt.sh SRC_FILE_NAME.txt


Please tell me how can I do this.

Regards, Deepti
# 2  
Old 07-14-2013
This User Gave Thanks to Yoda For This Post:
# 3  
Old 07-15-2013
Hi,

I have gone through the link and applied in my sed command but the argument is not working.

I am trying to modify an existing shell script which is doing etl validations.
below is the sed command where filename is hardcoded

Code:
sed 's/[^|]//g' /tmp/test/sample.txt

I have defined a parameter in the beginning of the shell script as
Filename=$1

And modified the sed command as below

Code:
sed 's/[^|]//g' /tmp/test/${"1"}

And passed the filename to the shell script as validate.sh sample.txt

but the argument is not working.

Please let me know if I am missing anything.

Regards,Gaur
# 4  
Old 07-15-2013
Remove that double quotes around 1:
Code:
sed 's/[^|]//g' "/tmp/test/${1}"

OR if you have assigned first argument to variable:- Filename:
Code:
sed 's/[^|]//g' "/tmp/test/${Filename}"

 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question