New answers tagged

2 votes

awk print between lines when "/" is part of the name

/regex/ is short for $0 ~ /regex/, which you can also write $0 ~ "regex", so besides escaping the / by prefixing it with \ or using \octal with the / character value (\57 on ASCII-based ...
Stéphane Chazelas's user avatar
2 votes

awk print between lines when "/" is part of the name

How can I print lines between those patterns? By replacing / with \57 records between patterns (and records with those patterns) can be printed. But please read this before using range expressions. $ ...
Prabhjot Singh's user avatar
1 vote
Accepted

awk print between lines when "/" is part of the name

When used inside an awk regular expression constant, the forward slash character must be escaped to distinguish it from the surrounding delimiters. For example with GNU awk: $ echo 'foo/bar was here' |...
steeldriver's user avatar
  • 79.6k
3 votes
Accepted

How does the `tr` command work?

tr’s arguments are maps of characters: characters are mapped 1:1 in order. In the set of replacements, the last character is repeated as necessary; extra characters are ignored. Thus tr 5 x replaces ‘...
Stephen Kitt's user avatar
1 vote

How does the `tr` command work?

IMO this behavior is explained perfectly in the macos tr man page: In the first synopsis form, the characters in string1 are translated into the characters in string2 where the first character in ...
jesse_b's user avatar
  • 36.4k
1 vote
Accepted

How to convert all newlines to "\n" in POSIX sh strings

Try awk with: string='x y ' new_string=$( LC_ALL=C awk -- ' BEGIN { gsub("\n", "\\n", ARGV[1]) printf "%s", ARGV[1] }' "$string" ) In any ...
Stéphane Chazelas's user avatar
0 votes

How to reverse a string made of digit in bash?

Given: $ echo "$s" 12345 6789 Here is a Ruby that reverses each line of input: $ echo "$s" | ruby -lpe '$_=$_.reverse' 54321 9876
drewk's user avatar
  • 241

Top 50 recent answers are included