I have a csv ( comma seperated value) file and I want to search for a particular string in each line of that file only if it occurs only once in the line.
That is same string may be present more than once in a line but I want it to be greped only when it occurs just once.
#!/bin/ksh
mFile='Your_File'
mStr='Your_String'
for mLine in `egrep ${mStr} ${mFile}`
do
mLine2=`echo ${mLine} | sed "s/${mStr}//2"`
if [ "${mLine}" = "${mLine2}" ]; then
echo $mLine
fi
done
Hi
Can any body help
I am writing a shell script and the parameter through command line is
orderlink=20
I am tring to get the substring
Example
String is orderlink=20 and I wanted to have substring after "="
my new string should be 20
The input string can be different as integration=15
This command works fine with GNU sed.
I tried the command on my AIX box, and i get the same error than you.
The t sub-command of sed interprets all that follows as being a label.
The following syntax is accepted on AIX :
sed -n -e '/the_string/{s/the_string//2;t' -e 'p;}' inputfile