Tag Info

New answers tagged

2

To replace first 10 digits with * if, and only if, the number has exactly 14 digits: sed 's/\([^0-9]\)[0-9]\{10\}\([0-9]\{4\}\)\([^0-9]\|$\)/\1**********\2\3/g' Example: $ echo 'foo bar 38012345678901 2014-02-11 22:23, 1134-53553, 4-5-6-7-7-2, 28012345678901,,,,, 3801234567890123456789 stuff' | \ sed ...


0

You can do it: cat gene_map_table_fb_2014_01_short.tsv |sed '1d' |awk {'print $2'} |awk 'BEGIN{FS=":"} {print $2}' |sed s/._//g At first cat your file, Then delete first line (header of columns with d1) , then print all of column, then seprate 4_FBgn0035847 with awk 'BEGIN{FS=":"} {print $2}' Then eliminate number_ with sed s/._//g Output is: ...


0

Using awk This creates tab-separated output: $ awk -v OFS="\t" 'NR==FNR{a[$1]=$2;next} FNR==1{print;next} {sub(/intron_/, "", $2); sub(/:.*/,"",$2);if ($2 in a) $2=a[$2];print}' gene_map_table_fb_2014_01_short.tsv HC25_LNv_ZT02_intron_results.txt bundle_id target_id length eff_length tot_counts uniq_counts est_counts eff_counts ambig_distr_alpha ...


2

It looks like your output is in some way encoded. You can try to pipe the output from grep through sed, it that is the only sequence you have to change: echo 'AAA"& #x5c;"BBB"& #x5c;"CCC' | sed 's/"& #x5c;"/\//g' will give you AAA/BBB/CCC


2

An awk solution: $ awk -v pat="$(awk '/SETTINGS START/,/SETTINGS END/' file2)" -v p=1 ' /SETTINGS START/{p=0};p;/SETTINGS END/{print pat;p=1}' file1 > file3 ANJALI NISHA // +++ CUSTOMIZATION SETTINGS START +++ WELCOME ALL // +++ CUSTOMIZATION SETTINGS END +++ PREETI MONA


2

You can use following sequence to only retain the account numbers (cudo's to J.D.Mohr) note the space after the r in the command :%norm $F,d$Bhv0r This assumes that there's only one , after the number you want to retain Breakdown : -> Enter command mode %norm -> Applies a normal command to the entire file $ -> Jump to end of line F, ...


0

As easy as it might be to want to use vim (or sed for this), awk is actually entirely capable of doing this type of matching and substitution all on its own: $ awk '{ sub(/^.* - /, ""); sub(/,.*$/, ""); print $0 }' file 23499 The above matches everything (with awk's built-in sub() function) from the beginning of the line to the hyphen and space before ...


0

If you would look for <account> (something like <12345>) and have have < and > only in <account>, as it looked like in the original version of the question, then this could work: %s/\v.*(\<.*\>).*/\1/ It matches < and > with anything between - which is in a group, and anything before and after in the line. That is ...


0

To get only the <account> string awk '{print $6}' file| sed 's/,//' >> newfile For possible future usage of the main data, this could be useful


1

You can have sed do the search and replacement like so. $ sed 's/mode v/mode sv/g' Example Say I have this sample file: $ cat afile.txt mode v modev mode v blah blah blah modev mode blah modev mode v I can use sed to search/replace this file and preserve a backup like so: $ sed -i.bak 's/mode v/mode sv/g' afile.txt I now have 2 files: $ ls -ltr ...


1

Your solution from comment works only if mode is the very first word in the line and replaces everything after "mode " with "sv". From your question I believe this is not your intention. There is no reason to complicate things, simple sed 's/mode /mode s/g' should work. Alternatively sed s/"mode "/"mode s"/g



Top 50 recent answers are included