Is there a command that...
Is there a command that extracts part of a file and puts it into another? Something like this:
$: extract [src file] [dest file] [offset] [size]
Like that? I think I remmeber seeing something one time that did something like this, but I can''t remember what it was.
Current Projects: GK3 for Linux | Landscape Engine | Bug Hunt
I like the DARK layout!
April 05, 2003 12:19 PM
dd if=inputfile of=destfile skip=numblocks count=numblocks bs=blocksize
dd is a block copy util so needless to say everything is done in counts of blocks. bs specifys block size (512 per default). skip seeks into the input file x blocks. count is the number for blocks to read (if left out it reads until eof). if "if" is left out then it reads from standered input. if "of" is left out it writes to standered out. also seek seeks a number of blocks into the output file before writing
dd is a block copy util so needless to say everything is done in counts of blocks. bs specifys block size (512 per default). skip seeks into the input file x blocks. count is the number for blocks to read (if left out it reads until eof). if "if" is left out then it reads from standered input. if "of" is left out it writes to standered out. also seek seeks a number of blocks into the output file before writing
You could cat the input file and do some filter to it. For instance, if you want all lines with the word "foo" in it, you would do this:
cat infile | grep foo > outfile
For a specific number of lines, say lines 4 through 16, I don''t know offhand, but I imagine it would be similar. cat to a filter that outputs the lines/characters you need and direct it to the other file. If you are concerned about what comes out, try using:
cat infile | grep foo
so you can see what it should say first before spitting out to outfile.
man grep to see what options it has. You can do word/line counts with some switches, for instance.
cat infile | grep foo > outfile
For a specific number of lines, say lines 4 through 16, I don''t know offhand, but I imagine it would be similar. cat to a filter that outputs the lines/characters you need and direct it to the other file. If you are concerned about what comes out, try using:
cat infile | grep foo
so you can see what it should say first before spitting out to outfile.
man grep to see what options it has. You can do word/line counts with some switches, for instance.
-------------------------GBGames' Blog: An Indie Game Developer's Somewhat Interesting ThoughtsStaff Reviewer for Game Tunnel
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement