sed is a command-line stream editor for filtering and transforming text.

learn more… | top users | synonyms

0
votes
1answer
36 views

have a log file that I would like to break up into several files based on content

I have a log file that I would like to break up into several files Table of Contents *** Configuration Database *** Logs *** Configuration Logs *** Query Logs . . and so on The issue ...
-1
votes
2answers
87 views

Have sed echo string after match

I need to have the string directly following/pbs.twimg.com\/profile_images\/echoed out. This is for a search tool I have created with a bit of help, and everyone recommends sed, but I never really use ...
3
votes
3answers
125 views

Replace a long string with the sed command: Argument list too long error

I'm trying to execute this command sed -i -e "s/BASE_64/$BASE_64/" FILE_NAME where $BASE_64 is a base 64 representation of a file content. sed gives me an error since the string is too long. ...
-4
votes
1answer
34 views

Can anyone explain in detail the following two commands regular expressions

The following two commands used to count no of non-zero integers of second column in the text file. Can anyone please explain the regular expression in detail. grep -c '^[^,]*,[^0][^,]*,' < myfile....
0
votes
0answers
38 views

sed can't find file on a shell script [duplicate]

I've been running into a problem whenever I run the shell script containing a sed. If I try this argument by running the shell script with the following line, it gives me a bizarre error: arg=$1; ...
-1
votes
3answers
35 views

Count non-zero numbers for each row of a second column in a text file

I have a text file in that each line words are separated by commas, like this: 7022122465,0,\N,,0,2015-09-29 10:48:33 7022597642,0,\N,,0,2015-09-29 10:48:33 7022848906,0,\N,,0,2015-09-29 10:48:33 ...
-1
votes
3answers
45 views

Insert array of years into a list of URLS

I have a list of URLS like the example below. /test/test I also have an array of years [1999, 2000, 2001]. I am trying to find a way to automate the task of printing out a list of URLS with ...
0
votes
1answer
98 views

sed use from android shell

I am getting familiar with sed on the android terminal emulation: the version I am using the sed included in the toybox which is installed on my unrooted Sony device. sed --version (or toybox sed --...
1
vote
2answers
49 views

sed + add last word on each string only if word not appears

I have the following file: linuxA.mtt.corp linux3V linux4B linux2A linux5v.mtt.corp how to add the .mtt.corp on each string that not have this word?
3
votes
2answers
204 views

sed command with option -n and '$='

I want to print number of lines in a file using the sed command. I have the following line for that, please can any one explain in detail. sed -n '$=' myfile.txt
1
vote
2answers
45 views

awk + how to append list in file

I have the following list in file more file.ex efifc1a hygg4a hdy5d nhdw4s wesf3a fjfhyr jfhg gsfar how to append any second list after the first list and any third list after the second list ...
0
votes
0answers
30 views

RE error: repetition-operator operand invalid

I'm getting this error RE error: repetition-operator operand invalid On FreeBSD sed, using csh. Command is: sed -rn 's/.*?VIEW ([^\s]+?) (AS .*?)\s([^\s]+?)\s([^\s]+?)/DROP VIEW \1;\nCREATE ...
0
votes
0answers
34 views

sed using a bash variable [duplicate]

I am attempting to identify 2 lines a in a file, that match a pattern (path) $ dir_target="./CUSTOM/Database/XXRBS/DML/Insert" $ cat csv.out ./CUSTOM/Database/APPS/DCL/Grant/xla_distribution_links....
0
votes
2answers
43 views

Renaming multiple files using sed

I have following set of files top_axi_256_wrapper_05.02.01.14.00_sample06.tgz top_axi_128_wrapper_05.02.01.14.00_sample06.tgz I want to replace 05.02.01.14.00 part with 05_02_01_14_00. So the ...
1
vote
2answers
87 views

Print text between multi-line delimiters

I am trying to extract data between 2 matching patterns, only if the content is not empty and I have issues doing it: here is an example: ============================== Queue Manager is : ...
1
vote
1answer
54 views

Replacing mysql settings with sed

I am creating a backup web server but I want the backup server to only have one root user. So after moving all the databases I need to replace all the mysqli_connect(...) lines in db.txt. I have ...
0
votes
2answers
77 views

Can sed save its output to a file?

> can do it. echo "text" > file tee can do it. echo "test" | tee file Can sed do it without using either of the above? Is it possible to save the output of a sed command to a file without ...
1
vote
1answer
22 views

How does this sed command works?

How does this sed line works : echo lred_6607: broken symbolic link to ./safaribooks/red_6607 | sed -e 's/^\|: *broken symbolic.*$/"/g' 1.There is no | character in the output of previous command. ...
1
vote
4answers
84 views

Impose character between repeated characters

Given a string of characters ,,a,,,b,,,, I want to impose the character - at the beginning, if no character is preceded comma, and between every comma that has no character. Meaning the result is -,-,...
1
vote
3answers
45 views

Unable to use a escape sequences in a variable in a sed command

I'm using sed to highlight a column in the output of a ps command, and it works fine if I hard code the color code. However, the color needs to be dynamic, so I tried moving it to a variable, and ...
2
votes
1answer
55 views

Highlight nth column of ps output

I'm trying to find the best way to highlight a specific column of some output. Specifically, I'm trying to highlight the 9th column (which is %cpu of the command: ps -eo pid,ppid,time,user,tty,%cpu,%...
1
vote
3answers
34 views

Text field with duplicate info

I have a tab-delimited data file with text fields, where some fields have duplicate information, semicolon delimited: 2000;2000 05/19/2016;05/19/2016 foo;foo How can I use sed to remove the ...
0
votes
1answer
57 views

Prepare update command using sed

I have a output file that contains 3 different column data- ['AARF'],SAMPLE12,2016-01-05 12:00:00-0500 ,529OFFST,2015-04-16 08:04:21-0400 "['EPROSP_IWS', '...
2
votes
4answers
401 views

How can I split a line into two lines if the length is greater than 7 using awk? [closed]

For example I just wanted to print something like this in the command line. Let say I have a file called file.txt. What is life? how are you? hi whatup this is more than And I want to print it ...
0
votes
2answers
60 views

How to determine what IP addresses are available in a hosts table?

I'm working on a script that will read from the /etc/hosts file and determine what IPs are available in the hosts file. The way the hosts file will look is as followed: 172.17.164.2 System1 172.17....
3
votes
2answers
32 views

Edit file based on existence of a string

I have an input file say file1 which appears as follows WRITE=2 START=1 SMEAR=0 MIN=6 MAX=100 My problem is to search for the string SMEAR and if the string exists replace the entire line with ...
-4
votes
1answer
37 views

How to change certain word in certain line in a file [duplicate]

i have a file in which i have to change a word and then save it by same name. for ex- for file "name"- my name is joe (original data) my name is roy (changed data) how to do it in best possible ...
0
votes
1answer
37 views

sed replace with value from an argument [duplicate]

Although this seems like a simple task, the sed call is not substituting the value that I send for IP. Instead, it is replacing localhost with "${IP}". substitute() { export IP=$1 echo $IP ...
0
votes
1answer
41 views

how to interpret “grep -Rl jdk1.7.0_80 . | xargs sed -i s,jdk17.0_80,weblogic”?

I have just installed Oracle weblogic on rhel server. Installation went successfully however the install guide given to me to run below command without explanation. I would like to know what I am ...
2
votes
5answers
96 views

Replacement of XML based on attribute content using sed

I've got to replace some attribute content in an XML tag, depending on a parameter $1. We've got in input, for example: <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="OO ...
0
votes
1answer
18 views

Log from a specific line to another specific line [duplicate]

I am doing a data monitoring and I am doing a cron job to get the data everyday. But I am receiving many junk data with my actual data that makes the file huge. For example my data is, eg.hh.jk.ll.mm ...
0
votes
0answers
26 views

Sed command for find and swap string [duplicate]

We are having the entry shown below in /etc/ldap.conf uri ldap://abccmnldap01.xyz.com ldap://pqrcmnldap01.xyz.com I want to swap abccmnldap01.xyz.com with pqrcmnldap01.xyz.com in ldap.conf with sed:...
1
vote
1answer
68 views

Replace one block of text with another block of text when replacement text is in a file

I have two files. The fist file is an existing C/C++ source file (*.cpp). The second is a text file (*.txt) and contains one function. The function is in both files, and it needs to be copied from the ...
-1
votes
1answer
38 views

Using sed to merge two lines [duplicate]

I'm trying to merge these two lines that appear periodically in a text file. travel_ by_night_and_day I have tried: sed '/_\nby/_by/s' input.txt > output.txt but, it doesn't do anything. Do ...
0
votes
1answer
32 views

sed - match on IP octet and remove line

I am in need of a solution, preferably sed, that can match on an IP octet that contains any number combination and remove the line. For example: My file: 192.168.100.12 192.168.200.12 10.10.20....
1
vote
3answers
123 views

add text on line before match

Trying to add text on the line before that it find the match (updateKey.sh) in this case, but won't get it to work. Here is my crontab file that the script adds the line to 0 06,18 * * * /home/server/...
0
votes
1answer
26 views

Linux red hat + replace PATH or word on scripts

Under folder: /var/userTN/applo folder I have around ~100 shell scripts that include the following PATH: GLOBAL_PATH=/export/pop/PLW5 I want to replace the PATH on all the scripts under folder: ...
0
votes
1answer
41 views

Bash add text on line script [closed]

Trying to get my script to work but it won't work. Here is my script #!/bin/bash a="* * * * * /home/server/scripts/check.sh" b="0 06,18 * * * /home/server/scripts/checks2.sh" sudo sed -i '28s/^/'$b'\...
0
votes
0answers
24 views

Preparing update command using sed

I have a sample input file- ,4.IM-H-506X,2016-01-01 11:07:27-0500 ['LOWERCASETEST7'],JASONTEST7,2015-04-19 00:00:00-0400 "['EPROSP_IWS', '648099_EPROSP_IWS']",4.NDR-IWS-EPRO,2015-04-16 08:...
1
vote
2answers
47 views

Is my interpretation of `sed -i.bak '/^x /d' “$SOME_FILE”` correct?

For some reason sed has always intimidated me, its syntax is a little odd I suppose. I want to make sure I understand what the following will do. sed -i.bak '/^x /d' "$SOME_FILE" This will first ...
1
vote
1answer
31 views

Parsing Data File's Lines by Delimiter Instead of EOL

I'm trying to parse a large text file (600MB) of raw data which I have no control on its format. The problem is that the end of line is not placed well: head -1 filename | wc -w Produces a count ...
1
vote
4answers
141 views

How to add a new text line at the first line of a file? [duplicate]

File: TABLE1 1234 9555 87676 2344 Expected output: Description of the following table: TABLE1 1234 9555 87676 2344
0
votes
2answers
36 views

Add newline character to file

Hi Guys i need to change the below single line string using a shell script {1:F01NESWSZM0AXXX1111111111} {2:I940BBRUBEBBXXXXN} {3:{108:400MSOG161200FRO}} {4: :20:400MSOG161200FRO :25:1xxxxxxxx65 :28C:...
0
votes
0answers
39 views

awk + how to manipulate awk output

The following awk command prints the results from services file # awk '{print $2}' /etc/services 48002/tcp 48002/udp 48003/tcp How can I manipulate the output so it prints the "service file" ...
0
votes
1answer
63 views

Replace 2 successive lines using sed

I've been trying to replace successive lines with the following sed commands : sed -i -e '/string1/{N;s/string2/string2_replaced/;N;s/string3/string3_replaced}' file1 sed -i -e '/string1/{n;s/...
3
votes
1answer
36 views

Replace a word after matched word with incrementing values

I have a file like this - ! interface csa2549abA xxxx yyyy zzzz ! interface aso23apwoeAe aaa bbb ccc ! interface FastEthernet0/1 ppp qqq rrr ! and so ...
2
votes
1answer
54 views

sed - Use file1 to find replacements contained in file2 for lines from file3 [duplicate]

I'm new here and haven't posted much, I'll try to make this as clear as I can. I want to perform a find and replace that involves three files: find.csv identifies lines containing strings. I want to ...
1
vote
1answer
28 views

Getting rid of a line with a perfect match (not substring) using sed

I want to delete a line which matches the word name but doesn't delete the lines have something following it. I can't seem to find an answer to this. I know sed -i '/name/d' * would delete the whole ...
2
votes
3answers
52 views

linux + ssh + perform two tasks in one ssh and print to CSV

the following command print the two values in one ssh shut ssh test01 "hostname && cat /etc/sysconfig/rhn/rhnsd " test01 INTERVAL=240 but how to change the syntax in order to print the ...
4
votes
1answer
413 views

How do I sort words by syllable count?

How do I perform an ascending sort of a word list, based upon how many syllables each word contains? Example Input: something important dog cat bookshelf Example Output: dog cat something ...