I see many examples and man pages on how to do operations like search-and-replace using sed. But, I want to match a given string or a regular pattern expression and display on the screen. How do I print lines with matching pattern using sed command only under Unix like operating systems?
I‘ve a file as follows:
This is a test.
One bang two three
Foo dang Bar
001 0xfg 0xA
002 0xA foo bar 0xfG
How do I delete all “words” from the above file which ends with a particular letter (say ‘g’) in each line? The output should be as follows:
This is a test.
One two three
002 0xA foo bar
How do I delete regex-based word using sed or awk under Linux / Unix like operating systems?
I got over 100s of HTML files in the following format:
my data 1
my data 2
my data 3
my data 10000
my data N times
How do I extract text between two words (<PRE> and </PRE>) in unix or linux using grep command?
I‘m using the date +’%D_%T’ to store Unix system date and time in a shell variable called $_now:
I’d like to replace / and : with _. I’m aware of the following sed command:
> s/:/_/g’ <<<"$_now"
How do I specify two pattern within the same sed command to replace | and : with _ so that I can get output as 01_20_12_16_10_42?
have a file called rsnapshot.conf. It has the words “ssh_args=-p 1222″. How do I match and remove (delete) the words “ssh_args=-p 1222″ from config file using sed command under Linux or Unix like operating systems?
My script depends upon $1 to take certain actions:
However, sometime there will leading while space which will result into:
How do I trim leading white space from one of my input variables?