Issue
How can I remove last line for this sed
cycle?
sed -n '/## bash, file, re/,/##/p' bash.kb
In my case, it shows me the last line too, last line with ##
string, which I need to remove.
Example.
Source file bash.kb
, this is text file.
...
## bash, file, remove last character on every line
sed 's/.$//' $file
## bash, files, watch only today's modified files
some command.
some 2nd command.
## bash, file, remove duplicate rows by column 1
sort -u -t, -k1,1 $file
## bash, file, exclude
command exclude
command exclude 2
## bash, file, remove all whitespaces from file
command
...
When I enter this command.
sed -n '/## bash, file, re/,/##/p' bash.kb
It will search for ## bash, file, re
and display output until next ##
, so with next ##
head line, which I need to remove.
## bash, file, remove last character on every line
sed 's/.$//' $file
## bash, files, watch only today's modified files
## bash, file, remove duplicate rows by column 1
sort -u -t, -k1,1 $file
## bash, file, exclude
## bash, file, remove all whitespaces from file
command
Output should be like this (implement sed '$d'
to every cycle? But how?).
## bash, file, remove last character on every line
sed 's/.$//' $file
## bash, file, remove duplicate rows by column 1
sort -u -t, -k1,1 $file
## bash, file, remove all whitespaces from file
command
Thanks.
If your input file has an empty line before every ##
line and only there, you can specify an empty line as the end of your range:
sed -n '/## bash, file, re/,/^$/p' bash.kb
^$
matches a line that has the beginning (^
), the end of the line ($
) and nothing in between.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments