Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem getting entire record when using grep on a file

Status
Not open for further replies.

rahill13

Technical User
May 30, 2002
6
US
I'm using grep to read a file and strip the header records out and feed it to another file. I'm not getting all of the record; grep is chopping off the tailend of the record. It looks like I only get 250 bytes of the record. Any suggestions???????

grep -v "***TOTAL***" file1 > file2


 
Not trying to sound un-helpful but maybe awk would work. Alternatively, I think perhaps you should try your line again with single-quotes instead of double-quotes. I like either awk or egrep because of the control that regular expressions give me.

I'm assuming that you are looking for asterisks rather than using them as wildcards. IBM Certified -- AIX 4.3 Administration
IBM Certified -- AIX 4.3 Support
IBM Certifiable!
 
If you're using the built in AIX version of grep, try downloading and installing the Gnu version. I found that other programs such as tar, cpio, etc. had issues with lengthy path names and the Gnu versions of these programs did not have the same issue.
 
Good point ECEBOB. rahill13, see earlier postings about line length limits in AIX.

If it is number of records, sed would work fine as it is a streaming sort of tool. Of course it is a bit arcane. IBM Certified -- AIX 4.3 Administration
IBM Certified -- AIX 4.3 Support
IBM Certifiable!
 
Hi!

If the task itself is no more than just filtering out some well known lines. grep will do. Only you have to give grep a correct expression.

As * has special meanings in regular expressions, you have to escape it like this:

grep -v \*\*\*TOTAL\*\*\* file1 > file2

and this way there is no need to use quotes. Or you may use single quotes which will suppress any special meanins of characters.

--Trifo



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top