Hi I have the following script which works in Linux shell but gives issues with Sun OS Solaris 5.10,
What i am trying to achieve here is we have a list of file names in list.txt file and we parse each file at a time for a particular pattern and copt next 4 lines after we hit the pattern to a file called report.txt
#!/bin/ksh
grep ^Table results.txt | grep :$ > $HOME/list.txt
cat $HOME/list.txt | while read line
do
echo $line
echo "***********************************" >>$HOME/Report
grep -A 5 "$line" results.txt >>$HOME/Report
echo "**********************************" >>$HOME/Report
done
when we use grep -A we get illegal option error, we used grep in /usr/xpg4/bin/grep still we face same issue and When we uncomment awk and use it the file prints nothing.
That will redirect the line that matches the pattern and the next four lines to the file $HOME/Report
If you need further help, do not hesitate to let us know.
Corona688 and gacanepa both missed a key point here. Unless they know that Yugendra's $PATH setting includes /usr/xpg4/bin or /usr/xpg6/bin before /bin and /usr/bin, they should explicitly use /usr/xpg4/bin/awk , /usr/xpg6/bin/awk , or nawk instead of awk in this script for it to work on Yugendra's Solaris systems.