Quote:
Originally Posted by
daPeach
what shell do you use?
it works allright for me using bash.
I tried sh and ksh , but I do not have bash in my environment. Thx.
---------- Post updated at 12:37 AM ---------- Previous update was at 12:32 AM ----------
Quote:
Originally Posted by
jim mcnamara
The IFS default value is white space. When a record comes out of a file as abc 123 it is seen as two fields.
Since you didn't specify what gave the problem I can't be more explicit.
So , in command line it is working shell is Posix, but inside my script like below , do I have to put IFS to another seperartor ?? :
#!/bin/sh
cat testfile > test2file
line2=" 456"
cat test2file |grep -i kernel |grep -v notsc | while read line
do
sed "s/$line/$line $line2/" test2file > test3file
cp test3file test2file
done
---------- Post updated at 03:06 PM ---------- Previous update was at 12:37 AM ----------
if I perform sed operation in command line there is no problem ??:
igui01# line1="kernel 600"
igui01# echo $line1
kernel 600
igui01# cat testfile
12345
678910
abcdefg
kernel
kernel bosluk notsc
kernel 123
kernel 600
kernel mevcut notsc
igui01# sed "s/$line1/$line1 notsc/1" testfile
12345
678910
abcdefg
kernel
kernel bosluk notsc
kernel 123
kernel 600 notsc
kernel mevcut notsc
I wonder what is root cause of a string in sed (in script)
split up to white space like this :
kernel 600 will turn to kernel ???