2
votes
4answers
43 views

Printing specific section of a line when a trigger value is present

I'm parsing data in the following format: prop1=value1:prop2=value2:prop3=value3+prop1=value4:prop2=value5 parts of the string are delimited by + properties can appear in any order the desired ...
0
votes
3answers
146 views

Awk/grep/sed get comma separated list of numbers from lines of text

I have a log file that has lines that look like this: blah blah blah Photo for (702049679 - blah blah blah Now I know I could get all the lines like that from the file by doing: grep "Photo for" ...
2
votes
3answers
60 views

Sed - string substitution with groupings

I have a largish directory with filenames formatted like Some_Folder-(FOL001)-clean what I'm trying to do is display the pattern between the brackets at the start like FOL001 ...
2
votes
2answers
273 views

How to write text into the first line of a file?

I've been looking around sed command to add text into a file in a specific line. This works to add text after line 1: sed '1 a\ But I want to add BEFORE line1. It would be: sed '0 a\ but I get ...
1
vote
4answers
526 views

How exactly do I create a sed script and use it to edit a file? [duplicate]

I know how to edit a file using sed one step at a time, but how would I create an actual sed script and then use it on the file to do the same things that the individual sed commands would do? For ...
1
vote
2answers
78 views

How would I use sed to detect a certain amount of numbers before it inserts a character? ###-###-####

I need to format phone numbers in a text file. They appear as (example) 8014516912 How would I format it so that I can insert a - after the first 3 numbers, and then another - after another 3 ...
0
votes
1answer
283 views

How can I get my sed command to make permanent changes to a file?

Is this possible? I read somewhere that the following command would do it: sed -e [command] [file] but it appeared to do the same thing as just sed [command] [file] (it did not save the ...
4
votes
4answers
387 views

What does <<< mean? [duplicate]

What does <<< mean? Here is an example: $ sed 's/a/b/g' <<< "aaa" bbb Is it something general that works with more Linux commands? It looks like it's feeding the sed program with ...
-2
votes
3answers
183 views

run file from different directory [closed]

I have a directory mainfolder with a subdirectory execution which contains a configure script. I can switch to the execution directory and run ./configure and it works fine. Now I'm trying to figure ...
5
votes
3answers
2k views

Use sed to find whole word and replace

I have the following block of text in a file: test3.legacy test4.legacy test3 test3.kami I only want to search for test3 as a whole and replace it with nothing. Unfortunately, all my attempts have ...
1
vote
1answer
173 views

Sed and Awk learning material [closed]

I'm looking for some learning material for sed and awk, can anyone make any suggestions? Please don’t refer to man and help pages. -O-
1
vote
1answer
139 views

Display words in color

I am looking for a tool which takes a file in input and a word to search. It should display the file with color the words if it corresponds to the search. Like grep --colors but displays all the ...
1
vote
1answer
192 views

Combining files with 4 columns each, into 4 files for each column [closed]

So I have a bunch of text files which look like this: T1 r1 a b c d r2 d e f g ... T2 r1 h i j k r2 l m n o ... And I want to make FOUR different text files in the following ...
5
votes
5answers
606 views

resolve all ip addresses in command output using standard command line tools

I have several log files that contain a bunch of ip addresses. I would love to be able to pipe the data through a program that would match and resolve ip addresses. I.E. cat /var/log/somelogfile | ...
2
votes
1answer
228 views

Replace “<?php print t('Blabla'); ?>” to be “Blabla”

Lets say in file.php, there is lots of php print text: <?php print t('Blabla'); ?>, <?php print t('Text Here'); ?>, etc. What I need is to remove <?php print t(' and '); ?> of the ...
2
votes
2answers
1k views

regex replace text in xml file within node from the command line

I have an XML file and I would like to replace everything that is between the open and closing tag within multiple instances of the g:gtin node with nothing. Is this possible from the command line, ...
4
votes
4answers
697 views

Replace whole line in a file from command-line

I have a text file which has some contents similar to this: # General information about the project. project = u'Py6S' copyright = u'2012, Robin Wilson' # The version info for the project you're ...
4
votes
3answers
1k views

Show lines matching a pattern and the 4 lines before each

For example, from this file: CREATE SYNONYM I801XS07 FOR I8010.I801XT07 * ERROR at line 1: ORA-00955: name is already used by an existing object CREATE SYNONYM I801XS07 FOR ...
6
votes
3answers
3k views

How do I grep without leading whitespaces?

I'm greping through a large codebase, and leading whitespaces and tabulation seem to be quite annoying. Is there any way to get rid of it? grep -R "something" ./ E.g, instead of: foo/bar.cpp: ...
2
votes
2answers
598 views

Change character position with sed

The file contains: dateutkfilename25012009 I want to change the position of character 16th to 17th with 18th to 19th. And then change position of character 16th to 19th with 20th to 23rd... so it ...
5
votes
4answers
221 views

How could I simplify this command to only use awk?

awk '/user/ {print $1 }' /etc/userdomains | sed 's/://' the format of /etc/userdomains is domain.tld: user otherdomain.tld: otheruser
8
votes
4answers
6k views

grep — removing text after delimiter token

I have a file in which I need to eliminate everything after the first ; on every line. So a file like this: sdfsdsdf; fsdfsddf;sdfsd; Will result in this: sdfsdsdf fsdfsddf I have looked into ...