I have to find the number of rows in a file and delete those many rows in another file.
For example, if I have 3 rows in a file A, i have to delete first 3 rows in anothe file B,
I have the code, it works as standalone, when I merge this with m application (c with unix), it doesnt work.
sed '1,'"`wc -l $tmp/b1rmrlooptmp | awk '{ print $1 }'`"'d' $tmp/b1rmr > $tmp/b1rmrtmpx
Anythign wrong here or can someone give me an alternate solution
zaxxon
2
Can't notice an error in the syntax. You can also write it a bit shorter so that awk is not needed to strip off the leading spaces of wc:
sed '1,'"`wc -l < $tmp/b1rmrlooptmp`"'d' $tmp/b1rmr > $tmp/b1rmrtmpx
Please show what error you get, ty.
Sorry did not read properly at 1st, changed my post - no offence.
This is how I have I have the code in my c program
strcpy(s, "sed '1,'\\\"`wc -l < $tmp/AA `\\\"'d' /tmp/BB > /tmp/CC");
system(s);
The expression doesnt get me any value. When I have the code without the expression as mentioned below, it works.
strcpy(s, "sed '1,3d' /tmp/AA > /tmp/CC");
system(s);
Is there any alternate way to do this in the unix