PDA

View Full Version : unix command expert here ?



garyng
06-02-2003, 06:08 AM
Just want to ask if there is readily available command to 'cut out' a part of a file, say from offset 12345 till end of file ?

another similar problem, any readily available command to 'grep' the first string occurrence in a file and return its offset.

I know I can write a perl script for that but just wondering if there is already something in the standard tool set.

Dave_Bechtel
06-02-2003, 09:59 AM
--See ' man dd ' (sorry, I haven't done this application myself so all I can do is point.)

See ' man grep ' -- ' grep -b ' will do exactly this. :)


Just want to ask if there is readily available command to 'cut out' a part of a file, say from offset 12345 till end of file ?

another similar problem, any readily available command to 'grep' the first string occurrence in a file and return its offset.

I know I can write a perl script for that but just wondering if there is already something in the standard tool set.

garyng
06-02-2003, 10:47 AM
thanks, the 'grep -b' option only works if the input is considered to be text and in my case it is binary and grep only want to say "match/not match" :cry:

Anyway, it seems to be pretty easy in perl so I went that route.

Dave_Bechtel
06-02-2003, 08:54 PM
--Cool. If you could post your code, it might be of help to others...


thanks, the 'grep -b' option only works if the input is considered to be text and in my case it is binary and grep only want to say "match/not match" :cry:

Anyway, it seems to be pretty easy in perl so I went that route.

garyng
06-03-2003, 07:35 AM
perl -e '$/="---unique seperator---";$i=0; while (<>) { print $_ if ($i++);}' combined_file