sed

How to extract characters between the delimiters using sed?

浪子不回头ぞ 提交于 2021-02-12 11:41:06
问题 I have just started learning sed. I want to extract and print the characters between the > and < delimiters. Here the text in my data file: <span id="ctl00_ContentPlaceHolder1_lblRollNo">12029</span> <br /><b>Engineering & IT/Computer Science</b><br /> <div id="ctl00_ContentPlaceHolder1_divEngITMerit"> <span id="ctl00_ContentPlaceHolder1_lblEngITSelListNo">3rd Provisional Selection List</span> <tr><td style='width: 200px' class='TblTRData'>IT/Computer Science/Software</td><td style='width:

Using an append pattern sed on AIX

☆樱花仙子☆ 提交于 2021-02-11 16:11:29
问题 I have been struggling trying to find a pattern with sed and then append a character on AIX. I have absolutely no problem on Linux, but I really don't get how it is supposed to work on AIX. Very simple : I have a /tmp/test.txt : 1 2 3 4 5 And I want : 1 2 10 3 4 5 So that I can understand how it works on AIX. On Linux, I can do sed -i '/2/ a 10\' /tmp/test.txt It works. On AIX, I know we have to do a work around because there's no -i. But even after looking at other topics like Find pattern

replace path value of a variable in file with bash

一笑奈何 提交于 2021-02-11 07:42:43
问题 I have a namelist containing inputs for simulations. I have to change the path of some variables using bash. The text file has the following value that I would like to change: opt_path = '/home/gle/test_workflow', I would like to replace the value of opt_path with cat and sed, and I tried the following but it doesn't work: new_path=/my/new/path cat namelist.wps | sed "s/^opt_path.*/opt_path = '${new_path}'/g" it returns the following error: sed: -e expression #1, char 29: unknown option to `s

Merging word counts with Bash and Unix

本秂侑毒 提交于 2021-02-10 19:52:28
问题 I made a Bash script that extracts words from a text file with grep and sed and then sorts them with sort and counts the repetitions with wc , then sort again by frequency. The example output looks like this: 12 the 7 code 7 with 7 add 5 quite 3 do 3 well 1 quick 1 can 1 pick 1 easy Now I'd like to merge all words with the same frequency into one line, like this: 12 the 7 code with add 5 quite 3 do well 1 quick can pick easy Is there any way to do that with Bash and standard Unix toolset? Or

Merging word counts with Bash and Unix

旧巷老猫 提交于 2021-02-10 19:51:53
问题 I made a Bash script that extracts words from a text file with grep and sed and then sorts them with sort and counts the repetitions with wc , then sort again by frequency. The example output looks like this: 12 the 7 code 7 with 7 add 5 quite 3 do 3 well 1 quick 1 can 1 pick 1 easy Now I'd like to merge all words with the same frequency into one line, like this: 12 the 7 code with add 5 quite 3 do well 1 quick can pick easy Is there any way to do that with Bash and standard Unix toolset? Or

awk FPAT to ignore commas in csv

百般思念 提交于 2021-02-10 17:02:00
问题 Sample.csv Data "2-Keyw-Bllist, TerrorViolencetest",vodka,ZETA+GLOBAL 4(ID: ZETA+GLOBAL),,105629,523,flag "2-Keyw-Bllist, TerrorViolencetest",vodka,Captify (ID: Captify),,94676,884,flag "2-Keyw-Bllist, TerrorViolencetest",vodka,QuantCast (ID: QuantCast),,46485,786,flag TerrorViolencetest,germany,QuantCast (ID: QuantCast),,31054,491,flag EY-Keyword-Blacklist,BBQ,MIQ+RON (ID: MIQ+RON),,26073,149,flag TerrorViolencetest,chips,Captify (ID: Captify),,23737,553,flag "2-Keyw-Bllist,

awk FPAT to ignore commas in csv

别说谁变了你拦得住时间么 提交于 2021-02-10 17:01:32
问题 Sample.csv Data "2-Keyw-Bllist, TerrorViolencetest",vodka,ZETA+GLOBAL 4(ID: ZETA+GLOBAL),,105629,523,flag "2-Keyw-Bllist, TerrorViolencetest",vodka,Captify (ID: Captify),,94676,884,flag "2-Keyw-Bllist, TerrorViolencetest",vodka,QuantCast (ID: QuantCast),,46485,786,flag TerrorViolencetest,germany,QuantCast (ID: QuantCast),,31054,491,flag EY-Keyword-Blacklist,BBQ,MIQ+RON (ID: MIQ+RON),,26073,149,flag TerrorViolencetest,chips,Captify (ID: Captify),,23737,553,flag "2-Keyw-Bllist,

awk syntax errors with double star **

烂漫一生 提交于 2021-02-10 14:59:45
问题 I'm using Debian 6 and GNU sed, trying to get awk to convert the output of du from a long string of bytes to a more human readable number with suffixes like Mb and Kb. (I know you can use the -h option, but I want to do this manually with awk.) So far, my command looks like this (I put in the newlines to make it more readable): du /test.img | grep [0-9]* | awk "{ sum=$1 ; hum[1024**3]='Gb';hum[1024**2]='Mb'; hum[1024]='Kb'; for (x=1024**3; x>=1024; x/=1024){ if (sum>=x) { printf '%.2f %s\n'

awk syntax errors with double star **

只愿长相守 提交于 2021-02-10 14:57:12
问题 I'm using Debian 6 and GNU sed, trying to get awk to convert the output of du from a long string of bytes to a more human readable number with suffixes like Mb and Kb. (I know you can use the -h option, but I want to do this manually with awk.) So far, my command looks like this (I put in the newlines to make it more readable): du /test.img | grep [0-9]* | awk "{ sum=$1 ; hum[1024**3]='Gb';hum[1024**2]='Mb'; hum[1024]='Kb'; for (x=1024**3; x>=1024; x/=1024){ if (sum>=x) { printf '%.2f %s\n'

Add/Replace URL Scheme in Info.plist using bash script

↘锁芯ラ 提交于 2021-02-10 13:48:13
问题 I want to add/replace the URL scheme in Info.plist file using bash script/command. I tried with sed command with various patterns but not succeeded. We want to automate the build generation using Jenkins and our URL Scheme can be changed for various builds, so we want to modify the Info.plist file such that we can either add a new URL Scheme if not there or replace the existing one using script/commands. Please suggest the command to achieve this. 回答1: Task set different url schemes for