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

[ad_1] 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 … Read more

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

[ad_1] 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 … Read more

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

[ad_1] 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 [ad_2] solved How can I manipulate text in bash? [closed]

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

[ad_1] 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 … Read more

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

[ad_1] 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 [ad_2] solved Replacing … Read more

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

[ad_1] 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 … Read more

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

[ad_1] 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 [ad_2] solved sed/regex to change only few of … Read more