[Solved] Bash: uppercase text inside html tag with sed

This will work only for your case and is not parsing HTML. DISCLAIMER First read: https://stackoverflow.com/a/1732454/7939871 This parsing with a sed Search-and-replace Regular Expression is a shortcut interpretation. It is in no way for use in any kind of production setup; as it would break on so many valid HTML syntax or layout variations like: … Read more

[Solved] Grep text between patterns using bash [closed]

Sed can do it as follows: sed -n ‘/^======/{:a;N;/\n——/!ba;/score +/p}’ infile ====== Ann Smith score + —— where -n prevents printing, and /^======/ { # If the pattern space starts with “======” :a # Label to branch to N # Append next line to pattern space /\n——/!ba # If we don’t match “——“, branch to … Read more

[Solved] What is the meaning of pwd|sed -e?

So first you should know that this is two commands – pwd and sed -e “s#/survey1##” – and these two commands are being run together in a pipeline. That is, the output of the first command is being sent to the second command as input. That is, in general, what | means in unix shell … Read more

[Solved] How can I manipulate text in bash? [closed]

With awk: awk ‘BEGIN{FS=”[ ,]”; OFS=”,”} {for (i=2; i<=NF; i++) print $i,$1}’ file Output: foo,ted bar,ted zoo,ted ket,john ben,john See: 8 Powerful Awk Built-in Variables – FS, OFS, RS, ORS, NR, NF, FILENAME, FNR solved How can I manipulate text in bash? [closed]

[Solved] Some troubles with using sed and awk [closed]

From what we can discern of this question, you’re attempting to create a programmatic rule to rename files ending in extensions stdout-captured, stderr-captured, and status-captured (assuming one typo) into files ending in extensions stdout-expected, stderr-expected, and status-expected, respectively. Obviously, if each of these definitions is inclusive of exactly one file, a rote mv may be … Read more

[Solved] Replacing first occurrence of comma in unix shell script

sed is your friend. The result can be stored in a new file. Give a try to this tested command below: sed s/,/\’,\’/ file.txt > result.txt The sed man page contains information. The test output: $ cat input.txt apple,orange,house foo,bar,woops $ sed s/,/\’,\’/ input.txt > result.txt $ cat result.txt apple’,’orange,house foo’,’bar,woops solved Replacing first occurrence … Read more

[Solved] Return not so similar codes from a single group [closed]

I would harness GNU AWK for this task following way, let file.txt content be 9003103 9003103 9003978 9003979 9003763 9003728 9003543 9003543 9003543 then awk ‘BEGIN{RS=””}{diff=$NF-$1;diff=diff>0?diff:-diff}diff>NF’ file.txt gives output 9003763 9003728 Explanation: I set RS to empty string to provoke paragraph mode, thus every block is treated as single line, then for each block I … Read more

[Solved] sed/regex to change only few of multiple matching characters

with sed based on position $ echo abc-def-ghi-2017-10-31 | sed ‘s/-/./4g’ abc-def-ghi-2017.10.31 based on surrounding chars $ echo abc-def-ghi-2017-10-31 | sed -r ‘s/([0-9])-([0-9])/\1.\2/g’ abc-def-ghi-2017.10.31 based on the position from the end of string $ echo abc-def-ghi-2017-10-31 | rev | sed ‘s/-/:/g; s/:/-/3g’ | rev abc-def-ghi-2017:10:31 2 solved sed/regex to change only few of multiple matching … Read more