Passing parameter through file

Hi ,

I am passing date parameter through file

my shell script testing.sh is

#set -x
#set -v
asd=$1
asd1=$2
echo $asd
echo $asd1

Passing parameter as below

sh testing.sh `cat file1.txt`

Output

cat file1.txt
'2014-08-18 17:18:07' '2014-08-18 16:10:01'
sh testing.sh `cat file1.txt`
"'2014-08-18
17:18:07'"

when i use

sh testing '2014-08-18 17:18:07' '2014-08-18 16:10:01'
2014-08-18 17:18:07
2014-08-18 16:10:01

This gives right output

How to pass the parameter by using output of file as input .

As your input 2014-08-18 17:18:07 already contains space .. you are getting that ouput
I have added pipe delimeter to your input file

$ more file1.txt
'2014-08-18 17:18:07'|'2014-08-18 16:10:01'

try

testing.sh "`awk '{print $1}' FS='|' file1.txt`" "`awk '{print $2}' FS='|' file1.txt`"

output

'2014-08-18 17:18:07'
'2014-08-18 16:10:01'

OR you want ouput on one line

testing.sh "`cat file1.txt`"
1 Like

awk works for me

Thanks