sed

How do I use the sed command to remove all lines between 2 phrases (including the phrases themselves)

I am generating a log from which I want to remove X startup output which looks like this: X.Org X Server 1.7.6 Release Date: 2010-03-17 X Protocol Version 11, Revision 0 Build Operating System: Linux 2.6.31-607-imx51 armv7l Ubuntu Current Operating System: Linux nvidia 2.6.33.2 #1 SMP PREEMPT Mon May 31 21:38:29 PDT 2010 armv7l Kernel c...

Change Number Format

I have a lot lines contains XXXXXXXXX-XXX.XXX number format. I want change number XXXXXXXXX-XXX.XXX to XX.XXX.XXX.X-XXX.XXX XXXXXXXXX-XXX.XXX = 15 digit random number Anyone can help me? Thanks in advance ...

Substitute the n-th occurrence of a word in vim

I saw other questions dealing with the finding the n-th occurrence of a word/pattern, but I couldn't find how you would actually substitute the n-th occurrence of a pattern in vim. There's the obvious way of hard coding all the occurrences like :s/.*\(word\).*\(word\).*\(word\).*/.*\1.*\2.*newWord.*/g Is there a better way of doing ...

sed variable replacement

I have tried this countless ways, time to throw in the towel and ask the master... #!/bin/bash # Read in the VERSION.header file, this is a plain text file # with returns, which in some of my tests, I am loosing the returns and getting # one string wrapped only by the shell width VERSION_HEADER=`cat VERSION.header` sed 's/_VERSION_HEA...

Shell scripting - running a regex to modify a file in place, that includes the file name.

I have many html files named 12345.html, 12346.html, etc. I need to change "style.css" to "style-12345.css" or the appropriate file name. I'm not sure what tool to use, recommendations? ...

awk and sed + append text after last line in file

how to append text line after the last line in file without using echo command need example in sed and awk THX yael ...

matching columns from two files

Dear all, I have two files, in which the first column of them might have same values. I would like to match the first column of both files, and print the lines in FILE1 for which there was a match. FILE1: xxx1 yyy yyy yyy xxx2 yyy yyy yyy xxx3 yyy yyy yyy FILE2: xxx3 zzzz xxx4 zzzz OUTPUT: xxx3 yyy yyy yyy Any suggestions are welco...

sed + need to remove each line in file that begin with ###

How to remove line that begins with three # For example need to delete all the following lines: from file 1 ### bla bla bal 2 ###blablabla 3 ### blabla . . . THX Yael ...

sed + delete line that begin with ### include space between line beginning and ###

hi all hi have: sed -i '/^###/d' file How to change the sed syntax in order to react like awk syntax? awk '!/^[ \t]*###/' file for example sed need to delete line that begin with space or TAB and then ### THX Yael ...

Question on sed command?

I am trying to use sed to delete parts of a text file with lines like: 23920 E S:1 R:2 C:14 L:5 ch 80 7279 1113 5272 -342 1168 5642 -347 1265 5587 23921 E S:1 R:2 C:14 L:6 ch 1 4605 1267 4586 11 1331 4587 -31 1306 4692 The parts I need to delete are the parts like E S:1 R:2 C:14 L:5 ch 80 and E S:1 R:2 C:...

Uncertain separator, parsing a messy log with sed

Hello, I'm working on #huge# text files (from 100mb to 1gb), I have to parse them to extract some particoular data. The annoying thing is that the files have not a clearly defined separator. For example: "element" 123124 16758 "12.4" "element" "element with white spaces inside" "element" I have to delete the white spaces in strings l...

Removing Parts of String With Sed

I have lines of data that looks like this: sp_A0A342_ATPB_COFAR_6_+_contigs_full.fasta sp_A0A342_ATPB_COFAR_9_-_contigs_full.fasta sp_A0A373_RK16_COFAR_10_-_contigs_full.fasta sp_A0A373_RK16_COFAR_8_+_contigs_full.fasta sp_A0A4W3_SPEA_GEOSL_15_-_contigs_full.fasta How can I use sed to delete parts of string after 4th column (_ separat...

Remove all the text using sed

Format: [Headword]{}"UC(icl>restriction)"(Attributes);(gloss) The testme.txt file has 2 lines [testme] {} "acetify" (V,lnk,CJNCT,AJ-V,VINT,VOO,VOO-CHNG,TMP,Vo) <H,0,0>; [newtest] {} "acid-fast" (ADJ,DES,QUAL,TTSM) <H,0,0>; The expected output is this: testme = acetify newtest = acid-fast What I have achieved so far is: cat te...

How to change the connection string with sed

Hello, guys! I have a connection string in a ini file as following: 1 ... 2 ... 3 #someline: n ConnectionString = "Data Source=localhost;Database=grid;User ID=grid;Password=grid;" And I would like to locate to the line n and replcate Data Source, Database, User Id and Password field. So how can I make it in sed? ...

Using SED to append a string to an existing line of text?

Hi, I'm trying to use the linux sed command to append a path element to the RewriteBase in a .htaccess file. I have tried it with this arguments: #current RewriteBase is "RewriteBase /mypath" sed -ie 's/RewriteBase\(.*\)/RewriteBase \1\/add/g' .htaccess with this result: addriteBase /mypath So sed overwrites the the beginning of ...

How do I remove newlines from a text file?

Hey there everyone ... I have the following data, and I need to put it all into one line... I have this: 22791 ; 14336 ; 22821 ; 34653 ; 21491 ; 25522 ; 33238 ; I need this: 22791;14336;22821;34653;21491;25522;33238; If anyone could help me it would be a great !! Thanks in advance! --------- EDIT No of these commands...

How to take out some of the new lines of a document

Hey there!! Firstly, I'm really new on this and I'm having difficulties... I have this data: [05/Apr/2010:09:59:34 -0300] /~bcc/topo-zero.html 200 238 2 [05/Apr/2010:10:01:19 -0300] /~bsi/materiais/ed/u6.html 200 286960 3 [05/Apr/2010:10:04:56 -0300] /~firedo/AISG/AISGroupContributions.html 200 33193 2 ...

Sed to remove underscores and promote character

Hi, I am trying to migrate some code from an old naming scheme to the new one the old naming scheme is: int some_var_name; New one is int someVarName_: So what I would ilke is some form of sed / regexy goodness to ease the process. So fundamentally what needs to happen is: find lower case word with contained _ replace underscore w...

delete whitespace at the end of number format

Hi.. I have several line contains number like: XXXXXX.XXX (this number ended by whitespace.) How can I delete whitespace at the end of number format using sed? Thank for the help. ...

sed + count words on field 3

hi all I used the following awk in order to count all words that appears in field 4 awk '{print $4}' file | awk '{print NF}' | grep -c 1 How we can to the same in sed? Example of file: 1 2 3 4 1 2 1 2 3 4 5 1 2 1 2 3 1 2 3 4 From file sed should return the results 3 (three words on field 4) yael ...