hi,
I need to number each occurrence of a pattern within a file using sed.
Given
object
0000
object
111
object
222
I need following
1.object
0000
2.object
111
3.object
222
Any help would be appreciated.
hi,
I need to number each occurrence of a pattern within a file using sed.
Given
object
0000
object
111
object
222
I need following
1.object
0000
2.object
111
3.object
222
Any help would be appreciated.
c=1; while read x; do echo $x | grep -q "object";
if [ $? -eq 0 ]; then
echo $x | sed "s/^/$c\. /"; c=$(($c + 1)); else echo $x;
fi;
done < input
Thank you.
Also i need to extract what is in between object one and two.
1.Objec
2222222aaaa
2.Object
222ddddd
3.Object
222ssss
I need
2222222aaaa
then
222ddddd
and so on...
$ nawk 'NR%2==0' infile
grep -v "object" inputfile
nawk '!NR%2' input.txt