hello,
i have a problem.
suppose
file.txt
i want to add lines over those lines in a file if it starts and ends with how and "?" respectively.
i want output like
output
file.txt
thanks
hello,
i have a problem.
suppose
file.txt
i want to add lines over those lines in a file if it starts and ends with how and "?" respectively.
i want output like
output
file.txt
thanks
Try this,
awk '/^how.*\?$/{printf "#asking\n#question\n"}1' filename
thankxxx
actually am new to this shell scripting so after taking an hour or so i wrote the below program.. phew :wall: :wall:.. its very lengthy though
#!/bin/sh
echo enter file1 name
read fname
exec<$fname
while read line
do
opt=${line:0:3}
if [[ "$string" =~ \ |\' ]]
then
echo ""
else
if [ "$opt" = "how" ]
then
echo "#asking"
echo "#question"
echo "$line"
else
echo "$line"
fi
fi
done
thanxx