Quote:
Originally posted by jedimastermopar
Strange on my test machine running redhat I can run sed with the -i flag but on my production machine -i is an invalid option? what is the -i?
It said invalid option --i
? isn't -i the flag to tell it to overwrite the file and -ie would be tomake and archive of the file with an e at the end?
|
The -i option is to edit the file in place, and the -e option is just telling sed to execute the following commands. You don't realkly need it if you are just giving sed one command, but you can string commands together with it.
Quote:
Originally posted by jedimastermopar
Also if a line looks like a blank line and it doesn't have a space in it what is it? The test files I was using are not the same as the real files I have to edit. When I run the script on a tes file with a blank line it works but when I take the real file sed doesn't seem to recognize the line as a blank line. but when I tell sed to just delete the line it can delete the line? very strange.
|
It could be that the lines are not actually blank, but have a space or tab in them.
Try:-
Code:
sed -i '/^[[:space:]]*$/{2d}' $1
to check for spaces as well.
EDIT: I should point out that if the "e" follows the "i", as in "-ie", then sed
will use the "e" as a suffix to back up the file.
p.s. You seem to have a pretty good grasp of sed now, how about looking at "man sed" to see all the options?