1
vote
5answers
135 views

How to split the output into different files?

I have a input file like foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz bar xxx yyy zzz bar xxx yyy zzz foo xxx yyy zzz .. How to split the input file by line, into foo.txt ...
1
vote
1answer
68 views

Replacing LineFeed \x0a with SED

I have to delete lots of Linefeeds (Hex \x0a) in a logfile. I just have sed to solve the problem. It is a bit complicated I know.. Do you have idea how to solve the problem? Here is an example ...
1
vote
2answers
48 views

I want to filter out two lines from the output of a program [closed]

I have a command that outputs a bunch of data, but I only want two lines. Grep doesn't work because the lines I want are not next to one another. I can't seem to figure out sed... Help please. :) ...
1
vote
1answer
133 views

sed replace inside shell file

I have a shell file which needs to perform a replace of some text in a php file. The line that needs replacing is: $database = $db."_db"; The actual sed command needs to contain a variable so not ...
1
vote
1answer
2k views

use sed in shell script to replace IP Address in a file

I have a script that finds a string in a file replaces it with a new string. $ sed -i 's/$old_string'/'$new_string'/g' $FILENAME Now I need the condition to be a regular expression that also check ...
2
votes
2answers
543 views

Prefix standard output before piping to a command

On Linux (Debian), how can I prefix the standard output of a command with one or several lines before piping it to a second command? This is for mailing the output of a command using sendmail like ...
0
votes
3answers
80 views

shell script + match MAJOR and CRITICAL strings from log file

I need to match lines that have MAJOR and CRITICAL strings that comes after the word ERROR:< any integer number > please advice how to do that with one awk or sed command? more HW_Log.txt ...
0
votes
2answers
329 views

How do I delete a matching line, the lines above and those below in the section?

In nagios config define service{ use generic-service host_name xxx.xxx.com service_description xxx Status check_command ...
3
votes
2answers
660 views

How do I use sed or awk to remove text?

I have the following line in a file: Linux Release............5.4.2.0-02 12_12_2011_07:31:23 How do I remove all characters before the first number with sed or awk? I wish to get the ...
2
votes
6answers
10k views

How to rename multiple files by replacing word in file name?

Replace ACDC to AC-DC For example we have these files ACDC - Rock N' Roll Ain't Noise Pollution.xxx ACDC - Rocker.xxx ACDC - Shoot To Thrill.xxx I want them to become: AC-DC - ...
1
vote
1answer
376 views

shell script to iterate through text files and delete a string

I have a few hundred text files in one directory with lists of users: &usera &userb userc &userd note that some do not lead with the &. Also, in some files, the last line does not ...
1
vote
1answer
1k views

use SED recursively in linux?

I want to implement the following command recursively sed -i 's/href=\"1\//href=\"\/1\//g' ./* so that it replaces all href="1 with href="/1 in all sub-directories. Is there a flag I can add to ...
1
vote
3answers
95 views

Taking this, and making that

I had no idea how to word the title. I need to take an output such as: [~]# cat file user1 domain1.com user2 domain2.com user3 domain3.com and turn it into an output such as: user1 domain1.com ...
3
votes
2answers
222 views

unix script problem

I have a simple script which runs on a FreeBSD machine with the following code: #!/bin/sh `sed -i .bak '\:#start 172.0.0.3:,\:#end 172.0.0.3:d' /usr/local/etc/racoon/racoon.conf` echo $? It should ...
0
votes
1answer
739 views

Cannot cd to parent directory with cd dirname

I have made a bash command which generates a one liner for restarting all Weblogic ( 8,9,10) instances on a server. The script works well but I need a suggestion to make it better using the dirname ...