it will be a lengthy explanation but ill do my best!
the syntax is separated by pipes '|'...that should help you break it down a bit so with that in mind lets take a look
the first part says im going to search a text file for a string, in this case File: and replace it with nothing, in other words, delete it.
if the '\' between 'File' and ':' are confusing this is where a tutorial on sed/regular expressions will come in handy. the '\' is seen as an escape character to search for a metacharacter as a literal (literals are alphanumeric) because in regular expressions metacharacters have special meanings, in this case is the ':'
so if we were to just run the first part we would get the following:
Quote:
sed 's/File\: //g' *INFILENAME*
IMAGE1.txt
Resolution: 720 x 547
IMAGE2.txt
Resolution: 720 x 547
IMAGE3.txt
Resolution: 720 x 547
|
so we take this current output and run a second sed statement against it, this is where the pipe '|' comes in, its basically taking the output from the first statement and giving it to the second statement to be manipulated further.
so with that in mind we end up taking:
Quote:
Quote:
IMAGE1.txt
Resolution: 720 x 547
IMAGE2.txt
Resolution: 720 x 547
IMAGE3.txt
Resolution: 720 x 547
|
and will get...
Quote:
IMAGE1.txt
720 x 547
IMAGE2.txt
720 x 547
IMAGE3.txt
720 x 547
|
by using this syntax
|
notice how we dont need to specify the input file again...
so now that we have the content that we want we need to arrange it...this is where it could seem confusing at first but the 'man' pages for sed are very informative and actually describe the option i used.
actually says to read a line 'N' then search for a new line '\n' and replace with a space. the space is necessary because without it the output would look like
- it will do this for all lines until its done...there are ways to specify how far down the text you want to read but thats not relevant at this time because we want to manipulate the entire content.
so the end result looks like:
Quote:
IMAGE1.txt 720 x 547
IMAGE2.txt 720 x 547
IMAGE3.txt 720 x 547
|
the last part
is basically saying whatever the final result is to go ahead and write it to a file
to get a better idea of how the "N" works (read or append each line) add an additional N separated by a ';' - you would get the first 3 lines on 1
i hope this helps