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

learn more… | top users | synonyms

3
votes
1answer
87 views

Search file name within file

Someone put a lot of malicious code onto every single wordpress instance on my server. For the second time. (At least) Every js file has been modified. There is a pattern though, the code always looks ...
3
votes
1answer
66 views

Replace Arbitrary Numbers of Word

Using sed, I want to replace patterns in the following way: --- >>> +++ --+-- >>> ++-++ --+-+-- >>> ++-+-++ --+-+-+-- ...
3
votes
1answer
54 views

Filter out inconsistent data blocks

I would like to filter out rows that has inconsistent geno values in line-part blocks. In case of duplicate consistent values , I would just keep the first row. As example, 'gf345 part1' has more ...
2
votes
1answer
81 views

How to get filenames when using find and sed

I am writing a script to apply sed on certain files and then list files that have been changed so that I know which have been modified. This is how I am finding and then using sed: find . -type f -a ...
2
votes
1answer
97 views

Modify filenames in Makefile

For reasons that are not important here, I have a source code that I process automatically file-by-file and the processed source files are renamed in a systematic manner. For example, I start out with ...
1
vote
1answer
53 views

Sed command usage without defining variables in shell script

I have two variables source_repo="fdl_ppe_01_04_repos_svc" target_repo="fdl_ppe_01_10_repos_svc" and I currently do a substitution within an XML file to replace all instances of $source_repo with ...
1
vote
1answer
27 views

Busybox ASH inside initrd has a problem when piping tee to sed

I'm trying to log the early boot output from the init script. This is what is working: mkdir -p /run/log && \ mkdir -p /tmp && \ mkfifo /tmp/stage-1-init.log.fifo1 && \ mkfifo ...
1
vote
1answer
31 views

Escape >');} < / in sed

In 30 files in 30 directories, I want to find: script>');} < /script> and replace it with: script>');} < /script--> What special characters do I need to escape in the find ...
1
vote
1answer
39 views

how can i comment out/in a section in source code with sed or awk

Currently i have files, which contain sections like this code statement1 code statement2 # BEGIN SOMENAME some code some other code # END SOMENAME code statement n +1 code statement n +1 What i ...
1
vote
1answer
56 views

Why doesn't this work when I add it to the current sed being run?

I have a text file that looks like this: (empty) str int int If I add this s/^/\</g to my current sed (making it 's/\&/\</g;s/\</\ /g;s/^/\</g') this is the output. < ##only ...
1
vote
1answer
35 views

display users that logged in since a date using last

I am trying to display the user name of the accounts that have logged in during the past month using the last command. At the moment I have this last | awk '{print $1, $4 ,$5 ,$6}' | grep -B 10 Jul ...
1
vote
1answer
88 views

How do I insert a character at the beginning of each line of a paragraph that contains a string

Sort of different request here: I have a text file in which I need to place a @ character at the beginning of each paragraph (paragraphs=separated by blank lines) that contains a certain search ...
1
vote
1answer
75 views

Remove and replace between two specific strings using sed command

Hi I have a SQL file i wanted to remove case statements which are present in a single line as well as case statements which are present in multiple lines. For example, my input file is: Select a, b, ...
1
vote
1answer
150 views

Sed regex printing into a file.txt

I'm connected to a MQTT stream, and I filter out the data by entering : mosquitto_sub -d -t +/# 2>&1 | sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;p}" into the Ubuntu terminal. ...
1
vote
1answer
175 views

substitute complex text string in several files that contains special characters

I need to replace a complex string in several files in a directory. The string that needs replaced is: ...
1
vote
1answer
144 views

Why doesn't this sed substitution for a non-ASCII byte work?

I tried this substitution with GNU sed on OS X (4.2.2 installed through Homebrew). But it doesn't work. printf "Hello\x92 World" | gsed -r "s/[\x92]/'/g" The expected output is: Hello' World The ...
1
vote
1answer
63 views

Create files from templates, substitutions in middle of other words

Is there a way to convince m4 to replace a macro in the middle of a word? I would like this file, day.m4: define(Sat,Cat)dnl Saturday and this command: m4 day.m4 to produce this output: ...
1
vote
1answer
540 views

How do I use the SED command to remove injected code from multiple files?

One of the domains on my Centos 6.5 (64 bit) server has been compromised. Having run a detection script on the public_html folder I have identified all the files with this code injection. I ...
1
vote
1answer
284 views

Insert a line after a block of text with sed

I have text file: file.conf ### Option: LogFile # Name of log file. # If not set, syslog is used. # # Mandatory: no # Default: # LogFile= ### Option: LogFileSize # Maximum size of ...
0
votes
1answer
42 views

How to make sed as fast as grep when replacing values

If I search with grep in a 30 gig database for some values it finds all of them in no time, if I run the same command with sed to replace those values it takes ages. Why is grep so much faster than ...
0
votes
1answer
53 views

replace long text string (script with MANY special characters). sed, awk, grep

My site was hacked / infected. I replaced the url of the malicious link, but other elements in the malicious script are still making my site get blocked. Without inserting a hundred or so "escapes", ...
0
votes
1answer
55 views

Sed command for performance improvement or tr command for the same

I have a command to replace the non printable characters and single quotes from a file but its taking more time to execute as I am replacing these characters for multiple files and the files size is ...
0
votes
1answer
29 views

Delete Non numeric row from a csv

I have used sed to allow only numeric and csv format ,I have used sed '/[^0-9, -, .]/d' as regex. It has still "_","1-0","1-1" character as o/p which worries me. sed 's/'"$(printf '\015')"'//g' ...
0
votes
1answer
24 views

Trouble using if string in column 3 of .csv exist, then statement

I have a set of 10 files. 5 are unique tumors tissues and the other 5 are matching normal tissues… So {tumor_A, normal_A, tumor_B, normal_B,… tumor_E, normal_E} These files each have a random ID, ...
0
votes
1answer
34 views

In bash I'm unable to concatenate a string using a variable defined from output of echo + sed

I'm trying to concatenate a string with $result. Placing another string BEFORE $result results in the two strings not being concatenated: ...
0
votes
1answer
42 views

copying a set of lines into new file

I have a text file with 100,000 lines or more. I want to copy specific lines from the text file into a new file using: sed -n '1,1000p;1000q' orig-data-file > new-file However, I want to create ...
2
votes
0answers
48 views

Awk /sed extract information when a pattern match from a paragraph

I want to search a pattern "FROM" in paragraph that begins with CREATE VIEW and ends with ";" and save the result in a csv file. for example if I have the following file : CREATE VIEW view1 AS ...
2
votes
0answers
230 views

Bash - Convert escape character colored text to BBCode

I want to convert a terminal escape-character colored text file to BBCode colored text. For this i've created an Android logfile with logcat -Cd > /sdcard/logcat.txt. The -C switch adds the color ...
1
vote
0answers
40 views

How to extract weather data from a html doc using linux string manipulation

I need to extract these info from this weather forecast site, but I don't know how much about string manipulation in linux: acm_RecentLocationsCarousel.push({name:"Irvine, CA", daypart:'day', ...
1
vote
0answers
119 views

Why is sed changing permissions of a file on a cifs mounted share?

I have an Arch linux machine that uses the following fstab entry to mount a share: //192.168.3.1/Documents /mnt/ cifs ...
1
vote
0answers
33 views

tab-delimiting a file in shell

I have a file that I want to put in a table in SQL with 10 columns. I am trying to tab-delimit the file so that the file can go in the table. Here is part of my txt file: Chr12 MSU_osa1r7 exon ...
1
vote
0answers
27 views

line 24: unterminated `s' command assistance

I'm trying to get an sgml file processed using openjade and I keep getting this error: line 24: unterminated `s' command I'm not familiar enough with sed to figure out where there should be a ...
1
vote
0answers
52 views

Using sed to unlock fields in a pdf

At my job we regularly unlock the fields of pdf files in order to edit them using this sed script in a .bat file: type %1 | sed -E 's/(.*\/T\([a-zA-Z0-9]*\).*)\/Ff 1(\/?.*)/\1\/Ff 0\2/' | sed ...
1
vote
0answers
122 views

sed stdin behaviour

Using sed for a direct stdin treatment of data, I expect that a line is treated after the enter. This is what happens when I test on CygWin or Linux but on my AIX, a second new line is needed to treat ...
1
vote
0answers
194 views

OpenWRT missing OD (octal dump)

I have a bash function using od command. Now I'm trying to run in on OpenWRT and see that in has not od. Also can't find it using install from opkg, because I can't find it. Is there a possibility to ...
0
votes
0answers
13 views

Dictionary - synonyms

I have czech czech-finnish dictionary and I have two czech synonyms in one row. Example: záchod (m); toaleta (f) WC; käymälä; miestenhuone; naistenhuone; vessa Synonyms are divided by semicolon ...
0
votes
0answers
29 views

How to add time stamp(month_year) to the file after matching specific string?

I want to add time stamp inside the file only after matching specific string, time stamp format: 03_2016 file contains "$channel_name Policy" string, I want to replace this string with ...
0
votes
0answers
136 views

How to redirect linux command outputs to specific row and column in csv?

I'm working on Unix Build post documentation process, I have a CSV file to be filled in and uploaded for every new build, to ensure the servers are build as per the original request. The CSV file ...
0
votes
0answers
47 views

How to write into local file and set its content to a variable within a ssh command substitution

I would like to write on local file (or local variable if better) and set its content to a variable within a ssh command substitution. Here is my code : REMOTE_OUTPUT=$(ssh remote@server /bin/bash ...
0
votes
0answers
53 views

“Cannot reallocate” when create file?

Am trying to create excel sheet base on multifiles on a root, I read files line by line append in the final excel sheet. Am trying this shell script on small files and it worked 100% bu when I try it ...
0
votes
0answers
24 views

In sed, what's the best way to apply blocks of commands to multiple addresses?

If I have a block of sed commands I want to apply to multiple addresses that aren't an address range, what is the best way to do this without repeating the block separately for each address? The only ...
0
votes
0answers
34 views

How to restore sbatch array job output file names to their original names

In order to submit array jobs using Slurm, I've renamed hundreds of files with incremental numbers using the following command: COUNT=1 for file in ./*; do mv "$file" "${COUNT}" let COUNT++ ...
0
votes
0answers
66 views

Sort Checkpoint Firewall log into easier output

I am trying to sort out this log: Aug 27 01:23:38 1.1.1.1/1.1.1.1/1.1.1.1 fw1-loggrabber[0000]: loc=12569|time=2015-08-27 ...
0
votes
0answers
65 views

Searching and replacing string using sed

Searching and replacing a string in a file. Input file name - Input.txt Following is the content: DATETIMEOFFSET(20) datetimeoffset(99) DatetimeOffset(10) lots of data1 lots of data2 ...
0
votes
0answers
208 views

tmux status bar path customization with sed

On the server I connnect to my home path is like this:/home/junk1/junk2/user. I can use the sed command pwd | sed -e 's|^/\([[:alnum:]]*\)/[[:alpha:]]*/[[:alpha:]]*|/\1|' to shorten the directory path ...
0
votes
0answers
116 views

SED: print entire paragraph for specific pattern while loop

I find partial answer about my problem on this question but i still have trouble. I need to use a variable as a pattern for the sed command in a loop sed -e '/./{H;$!d;}' -e 'x;/'$var'/!d;' The ...
0
votes
0answers
67 views

SED and regex expressions… addr1 and addr2

How can I use sed to match 'addr1' and reuse it again in 'addr2' field? #Ex.: echo "12a34" | sed 's/a/#bcd/g' # 12abcd34 #\# = match addr1
0
votes
0answers
38 views

to check fields in configuration file

i have configuration file in which first field is filename, second field is the column if we find the value of that column is null in the filename that is given in first column. if any of value of ...
0
votes
0answers
172 views

Find & replace image URLs in one file from another file

I am trying to replace all the image source URLs in an HTML file from a list of URLs in a text file. File1.html <td class="MetadataRes" width="380px" colspan="2" style="border-top: 1px #336699 ...
0
votes
0answers
755 views

Dynamic search and replace in Ksh

Machines at work follow a constant naming pattern: host[domain]_[id] where [domain] is either "d" for dev machines and "p" for production machines, and [id] is a 2-digit string that is different for ...