sed

Replacing newline escape '\n' with an escaped newline escape '\\n' using sed

送分小仙女□ 提交于 2020-05-15 06:50:46
问题 I am trying to replace the literal term \n (not a newline, the literal) by the literal \\n using sed . I've tried this: echo '"Refreshing \n\n\n state prior"' | sed 's/\\n/\\\n/g' This "works" but I need it to output the literal characters \\n . Right now I end up with something like this: "Refreshing \ \ \ state prior" Is there a way for me to maintain the \\n in sed output? 回答1: To get \\n add one more \ to your sed: echo "Refreshing \n\n\n state prior" | sed 's/\\n/\\\\n/g' What you were

How to pick multiple fasta sequences from a genes list

ぐ巨炮叔叔 提交于 2020-05-09 07:55:32
问题 I have two files The gene list file looks like this LOC_Os06g12230.1 Pavir.Ab03005 Pavir.J14065 ChrUn.fgenesh Sevir.1G325700 LOC_Os02g51280.1 Bradi3g59320 Brast04G017400 Fasta sequence file looks like this >LOC_Os03g57190.1 pacid=33130570 polypeptide=LOC_Os03g57190.1 locus=LOC_Os03g57190 ID=LOC_Os03g57190.1.MSUv7.0 annot-version=v7.0 ATGGAGGCGGCGGTGGGGGACGGGGAAGGCGGTGGCGGCGGCGGCGGGCGGGGGAAGCGTGGGCGGGGAGGAGGAGGAGG GGAGATGGTGGAGGCGGTGTGGGGGCAGACGGGGAGTACGGCGTCGCGGATCTACAGGGTGAGGGCGACGGGGGGGAAGG

How to pick multiple fasta sequences from a genes list

我与影子孤独终老i 提交于 2020-05-09 07:55:08
问题 I have two files The gene list file looks like this LOC_Os06g12230.1 Pavir.Ab03005 Pavir.J14065 ChrUn.fgenesh Sevir.1G325700 LOC_Os02g51280.1 Bradi3g59320 Brast04G017400 Fasta sequence file looks like this >LOC_Os03g57190.1 pacid=33130570 polypeptide=LOC_Os03g57190.1 locus=LOC_Os03g57190 ID=LOC_Os03g57190.1.MSUv7.0 annot-version=v7.0 ATGGAGGCGGCGGTGGGGGACGGGGAAGGCGGTGGCGGCGGCGGCGGGCGGGGGAAGCGTGGGCGGGGAGGAGGAGGAGG GGAGATGGTGGAGGCGGTGTGGGGGCAGACGGGGAGTACGGCGTCGCGGATCTACAGGGTGAGGGCGACGGGGGGGAAGG

how to write a SED script to replace the version code present in a file based on user input using Regex

好久不见. 提交于 2020-05-09 07:16:08
问题 I am taking the version code from user input and trying to replace the existing version code with the new one. The file which contains version code is named "Version.gradle" , it contains defaultConfig { applicationId "com.service_app" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" } I am able to get the version from user, but I don not know how to replace the new version code with exiting one. I am using the below

Regex to get title from magnet link: “unterminated address regex”

十年热恋 提交于 2020-04-30 09:07:53
问题 I am trying to create a simple shell script to get the title from a magnet link and write it to a .out file. If I try out on regex101.com the below regex, there is a hit. See screenshot. &dn=(.*?)& (https://imge.to/i/Fw26r) The problem is that I get the following error all the time: "unterminated address regex". I tried different options, yet same result: u@d:~/Documents/tmp $ sed -e '\&dn=(.*?)\&$' magnet.txt >> magnet.out sed: -e expression #1, char 13: unterminated address regex u@d:~

Storing String Output of SED Commnd in an Array In Shell Script

痴心易碎 提交于 2020-04-18 05:49:39
问题 I have an XML file of the format: <classes> <subject lb="Fall Sem 2020"> <name>Operating System</name> <credit>3</credit> <type>Theory</type> <faculty>Prof. XYZ</faculty> </subject> <subject lb="Spring Sem 2020"> <name>Web Development</name> <credit>3</credit> <type>Lab</type> </subject> <subject lb="Fall Sem 2021"> <name>Computer Network</name> <credit>3</credit> <type>Theory</type> <faculty>Prof. ABC</faculty> </subject> <subject lb="Spring Sem 2021"> <name>Software Engineering</name>

How to pass special character string to sed [duplicate]

女生的网名这么多〃 提交于 2020-04-17 22:50:38
问题 This question already has answers here : How to escape single quote in sed? (7 answers) Closed last month . Am trying to pass special character string to sed command but no success i tried backslash but no success sed -i 's/old/new/g' {} + # working sed -i 's/$_REQUEST['old']/$_REQUEST['new']/g' {} + # not working sed -i 's/$_REQUEST[\'old\']/$_REQUEST[\'new\']/g' {} + # not working sed -i "s/$_REQUEST['old']/$_REQUEST['new']/g" {} + # NIGHTMARE ! not working 回答1: It's not possible to include

How to pass special character string to sed [duplicate]

冷暖自知 提交于 2020-04-17 22:50:21
问题 This question already has answers here : How to escape single quote in sed? (7 answers) Closed last month . Am trying to pass special character string to sed command but no success i tried backslash but no success sed -i 's/old/new/g' {} + # working sed -i 's/$_REQUEST['old']/$_REQUEST['new']/g' {} + # not working sed -i 's/$_REQUEST[\'old\']/$_REQUEST[\'new\']/g' {} + # not working sed -i "s/$_REQUEST['old']/$_REQUEST['new']/g" {} + # NIGHTMARE ! not working 回答1: It's not possible to include

How to pass special character string to sed [duplicate]

混江龙づ霸主 提交于 2020-04-17 22:45:18
问题 This question already has answers here : How to escape single quote in sed? (7 answers) Closed last month . Am trying to pass special character string to sed command but no success i tried backslash but no success sed -i 's/old/new/g' {} + # working sed -i 's/$_REQUEST['old']/$_REQUEST['new']/g' {} + # not working sed -i 's/$_REQUEST[\'old\']/$_REQUEST[\'new\']/g' {} + # not working sed -i "s/$_REQUEST['old']/$_REQUEST['new']/g" {} + # NIGHTMARE ! not working 回答1: It's not possible to include

Replace every occurrence of a word with each line from an list-file

99封情书 提交于 2020-04-16 03:57:12
问题 I want to name each .tar file in the code below and name it based on a list-file that contains the names, but I don't want to mess with the exclusion tag. I have a list file and I was thinking of using a text editor and adding cvf to the beginning of each line I have in a list and then use sed to replace the string cvf , thus adding the flag and then the name follows. i.e. cvf name1 cvf name2 cvf name3 I tried using sed 's/cvf/word2/g' input.file and as expected it only replaces cvf with the