sed

RegEx Matching on text and new line

馋奶兔 提交于 2020-06-01 02:17:30
问题 I have a file which appends a binary file to a bash script (in this case an ISO). It ultimately gets pulled apart, executing the bash script to install the ISO. The bash script ends in a unique string; " DATA " and during its execution the script deletes everything above and including that line. It doesn't however remove the terminating new line which means the new file (which should just be the binary ISO data) begins with a newline, breaking the ISO. The regex deleting the data is as

RegEx Matching on text and new line

你。 提交于 2020-06-01 02:14:08
问题 I have a file which appends a binary file to a bash script (in this case an ISO). It ultimately gets pulled apart, executing the bash script to install the ISO. The bash script ends in a unique string; " DATA " and during its execution the script deletes everything above and including that line. It doesn't however remove the terminating new line which means the new file (which should just be the binary ISO data) begins with a newline, breaking the ISO. The regex deleting the data is as

Exact Regex expression for floating point number is not working

久未见 提交于 2020-05-30 09:55:04
问题 Exact regex expression for floating point number is not working and it execute both integer and floating point also.It should not work if the input given does not have decimal point.Please help me #!/bin/bash echo "Enter version code" read versionName if ! [[ "$versionName" =~ ^[+-]?[0-9]+\.?[0-9]*$ ]]; then echo "Sorry decimal numbers only" echo "$versionName" else sudo sed 's/\(versionName[[:space:]]*\)"[0-9.]*"/\1"'"${versionName}"'"/' test.txt fi 回答1: Use this: ^[+-]?[0-9]+\.[0-9]+$ ^ no

Exact Regex expression for floating point number is not working

℡╲_俬逩灬. 提交于 2020-05-30 09:54:49
问题 Exact regex expression for floating point number is not working and it execute both integer and floating point also.It should not work if the input given does not have decimal point.Please help me #!/bin/bash echo "Enter version code" read versionName if ! [[ "$versionName" =~ ^[+-]?[0-9]+\.?[0-9]*$ ]]; then echo "Sorry decimal numbers only" echo "$versionName" else sudo sed 's/\(versionName[[:space:]]*\)"[0-9.]*"/\1"'"${versionName}"'"/' test.txt fi 回答1: Use this: ^[+-]?[0-9]+\.[0-9]+$ ^ no

Find, decode and replace all base64 values in text file

|▌冷眼眸甩不掉的悲伤 提交于 2020-05-28 04:58:06
问题 I have a SQL dump file that contains text with html links like: <a href="http://blahblah.org/kb/getattachment.php?data=NHxUb3Bjb25fZGF0YS1kb3dubG9hZF9ob3d0by5wZGY=">attached file</a> I'd like to find, decode and replace the base64 part of the text in each of these links. I've been trying to use Python w/ regular expressions and base64 to do the job. However, my regex skills are not up to the task. I need to select any string that starts with 'getattachement.php?data=' and ends with '"' I then

Replace literal “\r\n” in text file

亡梦爱人 提交于 2020-05-24 06:42:50
问题 I am trying to replace each \r\n in a text file with <p/> . I have tried the following with no luck: sed 's#\r\n#<p/>#g' test.txt sed 's#\r\n#<p/>#g' test.txt sed 's#/\r/\n#<p/>#g' test.txt sed ':a;N;$!ba;s/\r\n/<p/>/g' test.txt Here is the text in text.txt https://www.pivotaltracker.com/story/\r\nhttps://www.pivotaltracker.com/story\r\n\r\nSome business text.\r\n\r\nSome business text. Task 123 is still a work in progress but we wanted it in develop to keep everything updated. 回答1: All of

What is the significance of -n parameter passed to sed command?

天涯浪子 提交于 2020-05-24 02:46:48
问题 Can someone please tell me how does sed -n '1!p work ? Below is the full command which I am using to sort my pods in k8s based on nodes they are assigned. kubectl get pods -o wide --all-namespaces|sort -k8 -r| sed -n '1!p' The above command works perfectly and the sed part removes the first header line from the final output. I want to understand how does the sed part work and what's the significance of the parameters passed to sed ? 回答1: From info sed : -n : By default, 'sed' prints out the

keep fasta records which have 2 matches of OX values

╄→гoц情女王★ 提交于 2020-05-16 22:05:49
问题 I have a file that looks as follows : >sp|rin-1 ghsfdhjkuesl OX=10116 GN=Cdh1 PE=1 SV=1|sp|P10287|ghsfdjdeosd gdhkhs OX=10090 GN=Cdh3 PE=1 SV=2 WRDTANWLEINPETGVISTRAEMDREDSEHVKNSTYTALIIATDDGSPIATGTGTLLLVLSDVNDNAPIPEPRNMQFCQRNPKPHVITILDPDLPP >sp|erin-1 ghsfdshkd OX=10116 GN=Cdh1 PE=1 SV=1|sp|P22223|CADH3_HUMAN Cadherin-3 OX=9606 GN=CDH3 PE=1 SV=2 ESYPTYTLVVQAADLQGEGLSTTAKAVITVKDINDNAPIFNPSTYLQCAASEPCRAVFREAEVTLEAGGAEQEPGQALGKVFMGCPGQEPALFSTD >sp|n-1 ghsfd OX=10116 GN=Cdh1 PE=1 SV=1|tr|F1LMI3

keep fasta records which have 2 matches of OX values

怎甘沉沦 提交于 2020-05-16 22:05:17
问题 I have a file that looks as follows : >sp|rin-1 ghsfdhjkuesl OX=10116 GN=Cdh1 PE=1 SV=1|sp|P10287|ghsfdjdeosd gdhkhs OX=10090 GN=Cdh3 PE=1 SV=2 WRDTANWLEINPETGVISTRAEMDREDSEHVKNSTYTALIIATDDGSPIATGTGTLLLVLSDVNDNAPIPEPRNMQFCQRNPKPHVITILDPDLPP >sp|erin-1 ghsfdshkd OX=10116 GN=Cdh1 PE=1 SV=1|sp|P22223|CADH3_HUMAN Cadherin-3 OX=9606 GN=CDH3 PE=1 SV=2 ESYPTYTLVVQAADLQGEGLSTTAKAVITVKDINDNAPIFNPSTYLQCAASEPCRAVFREAEVTLEAGGAEQEPGQALGKVFMGCPGQEPALFSTD >sp|n-1 ghsfd OX=10116 GN=Cdh1 PE=1 SV=1|tr|F1LMI3

keep fasta records which have 2 matches of OX values

烂漫一生 提交于 2020-05-16 22:05:02
问题 I have a file that looks as follows : >sp|rin-1 ghsfdhjkuesl OX=10116 GN=Cdh1 PE=1 SV=1|sp|P10287|ghsfdjdeosd gdhkhs OX=10090 GN=Cdh3 PE=1 SV=2 WRDTANWLEINPETGVISTRAEMDREDSEHVKNSTYTALIIATDDGSPIATGTGTLLLVLSDVNDNAPIPEPRNMQFCQRNPKPHVITILDPDLPP >sp|erin-1 ghsfdshkd OX=10116 GN=Cdh1 PE=1 SV=1|sp|P22223|CADH3_HUMAN Cadherin-3 OX=9606 GN=CDH3 PE=1 SV=2 ESYPTYTLVVQAADLQGEGLSTTAKAVITVKDINDNAPIFNPSTYLQCAASEPCRAVFREAEVTLEAGGAEQEPGQALGKVFMGCPGQEPALFSTD >sp|n-1 ghsfd OX=10116 GN=Cdh1 PE=1 SV=1|tr|F1LMI3