"sed" ("stream editor") is a Unix utility that parses and transforms text files.

learn more… | top users | synonyms

0
votes
0answers
52 views

Ping multiple domains from file and out only desired IP

Need bash script to ping multiple domains from file and output just domains with adress ip : 1.2.3.4 exemple (domains.txt): www.google.com support.mozilla.com stackexchange.com support.mozilla.com ...
0
votes
0answers
108 views

How to enable Bitlocker hardware encryption on Bare-Metal VHDX

I have a Crucial MX200 SED, and I want to use the hardware (not software) encryption on VHDX disks, including the operating system VHDX. The SED is OPAL 2 compliant. However, the Crucial website ...
1
vote
2answers
36 views

insert a string between two patterns

I would like to change file with name like: d1-a2_A1_B1.txt abcd_A90_B2.txt where I want to insert _FOO in between first _A[0-9]\+ and _B[0-9] so the file names becomes d1-a2_A1_FOO_B1.txt ...
1
vote
1answer
32 views

sed, delete from MarkA up to but not include MarkB

Expression in math term, I'd like to delete a region of [MarkA,MarkB). I.e., the deletion happens right when the keyword MarkA is encountered, all the way to keyword MarkB, but not including that line ...
1
vote
1answer
32 views

How do I get rid of odd bytes from this output?

So, for my statistics class, I've been using a lot of linux trickery to organize my numbers, copy/paste them around, etc. Now, I haven't had any issues until just recently... I had copy pasted a bunch ...
0
votes
2answers
56 views

remove pattern with random numbers (digits) from php files

I am trying to remove or replace the digits ((random numbers)) in big numbers of php files using find & xargs and grep with sed etc .. the numbers looks like that inside the php file ...
1
vote
1answer
46 views

How to find the last 2 characters of Chinese names with command lines tools?

I have a list of Chinese names, some of them have 2 characters, others may have more or less, like following: I want to use some command lines tools, to find the last 2 characters of each. If ...
0
votes
1answer
29 views

How to delete text after a marker

I’ve got a piece html code And I try to extract the first paragraph. html is like this : <p> Hi. Lorem Ipsum<br /> dolor si amet […] </p> <p>…</p> ...
1
vote
1answer
23 views

remove wayback toolbar code in bewteen lines

I am trying to remove Wayback toolbar code using some tools such as find & xargs and grep with sed etc issue that the size of the html & php files it's over 7GB & as well as the pages ...
0
votes
1answer
120 views

Merging two files in unix, with one common column that is redundant

I have two files with one common column that is redundant.File 1 has chromosomal locations and TF's, file 2 has chromosomal locations and Refseq numbers. File 1: ...
0
votes
1answer
20 views

Converting from vim search to sed

I have a long Latex document with many sections. I'd like to check that all sections of the document are filled in. So I search for any time there is a '}' ending a section title, somewhitespace, and ...
0
votes
3answers
118 views

How do I replace numbers in specific field bash

I am using FreeBSD 3.2-RELEASE. For example output from last- abelovsk14 1 10-7 22:06 adamov14 5 10-5 22:53 almasi14 1 10-8 22:56 anda13 53 10-6 22:16 andrejko14 51 10-7 01:28 Is possible to ...
1
vote
2answers
71 views

sed pattern with multiple words to update

I want to do something like this, but I'm not sure how. I want to update the exports.version = '2.0.0' to a new value of exports.version = '2.0.1' Using: sed -i '.bak' 's/'2.0.0'/'2.0.1'/g' ...
1
vote
1answer
46 views

How to replace text between two unique strings in file?

In requirements.txt, I want to replace the branch/commit which can contain forward slashes, dashes, and other potentially special characters that may need escaping: -e ...
2
votes
2answers
78 views

How to add # Shebang in first line of a file which is an auto create script by another program

I am looking for a method to add a shebang #!/bin/csh -f to first line of my file , which is actually getting created by a another set of program, since this script is auto-created, it should run from ...
1
vote
1answer
39 views

Weird behaviour of 'sed' utility

I'm using sed on Windows by the GnuWin32 port. I have a text file input.txt with this contents ab I tried these combined commands to separate the a character into a new line and then to delete the ...
2
votes
2answers
74 views

Sed/Awk save text between patterns if contains string

I'm facing an issue with mails. I need to get all messages between 2 people: somebody1@domain.com and person@domain.com. The file: From: somebody1@domain.com to: person@domain.com <body of the ...
0
votes
2answers
24 views

shell - multiple text insertion into each line of a file

I have a text containing coordinates of points such as x, y and z, I would like to change each line to be like: Point{ (1000+linenumber) } = {x , y, z}; What I want is: for example for line 212 ...
1
vote
3answers
117 views

linux - replace all double newlines with a space

Is it possible to replace only double newlines in a text file using sed, awk, grep, tr, or whatever is needed? this is data this is more data What I need to do is to replace all double ...
0
votes
1answer
71 views

Printing matching subgroups in a perl one liner

I have the regex[1] (/foo/bar/(GW|GREV)[^/]*).* I was able to get this to work with GNU sed with sed -n 's/\(\/foo\/bar\/\(GW\|GREV\)[^\/]*\).*/\1/p' But that was a modern GNU sed and I'm on ...
1
vote
2answers
253 views

Remove carriage returns in text file via the Terminal in Mac OS X 10.10 (Yosemite)

I’m trying to replace all carriage returns with a comma in a text file but I must be using the sed command improperly. Since I can echo -e "\x0D"and yield the carriage return I tried sed -e ...
0
votes
2answers
271 views

Ubuntu command line to replace replace single quotes ( ' ) with double quotes (")

I’ve recently downloaded a photo album website template and I want to make it easy for my non-tech savvy life mate to add photos to. It uses an XML file which requires editing each time photos are ...
-1
votes
1answer
174 views

python script equivalent to sed command

I have sed command : sed -r 's/^((.){20})/\n/' log1.txt which ignores first 20 charcters of file log1.txt. what is the pythonic equivalent to this sed command??
1
vote
0answers
212 views

The system cannot find the file specified error when using subprocess.check_output()

I have a sed command like : sed -r 's/^((.){20})/\n/' log1.txt I want the above command to be executed in python script. I tried something like this : path = 'log1.txt' sedcmd = 's/^((.){20}/\n/' ...
0
votes
2answers
65 views

2 questions re Self Encrypting Drives (SED)

Can the SED be “turned on” with documents and files already on the computer? Are they affected in any adverse way? I have a laptop with SED that I’m wanting to use in a small work environment that ...
1
vote
1answer
101 views

Command not working on shell but working on prompt

I am a newbie to Linux Shell Script. I want to change the IP address by Linux Shell Script and called by a PHP web application. I have finished my PHP web application and the shell script. Before ...
1
vote
1answer
202 views

sed option to preserve file times during a find/replace?

I'm trying to modify some Autotool files because a project is not honoring my CFLAGS, CXXFLAGS and LDFLAGS. I located some areas where I could likely make the change with a grep for libtool: link. ...
1
vote
1answer
28 views

How to remove pattern containing blank space and special characters in sed

How to remove following words from a text file: DEFAULT ('') DEFAULT ((0)) DEFAULT (((1)/(1))/(1900)) DEFAULT (getdate()) I am not able to delete above four pattens using sed.
0
votes
1answer
20 views

Quotes in sed when used in bash script

I am generating sed expression in Bash script, and I am having a following problem. I want to add a space in front of each appearance of abc. This commands works as expected echo abc | sed -e ...
-1
votes
1answer
35 views

bash change strings with multiple escape characters

Hello i try to automate for example change one variable in php file . root /tmp # cat defaults.inc.php|egrep "reply_all_mode" $config['reply_all_mode'] = 0; I try to first catch this by grep ...
0
votes
2answers
32 views

How can I replace a newline with its escape sequence?

Using sed to make text that contains certain characters suitable for use in string literals is straightforward: sed "s/\\\\/\\\\\\\\/g" sed "s/\\\"/\\\\\\\"/g" But how can I do something similar ...
1
vote
2answers
99 views

How to execute command and use it's result in sed correctly?

I have a config file in JSON format with following block "device" : { "name" : "MyPi", "type" : "ws2801", "output" : "/dev/spidev0.0", "rate" : 250000, ...
0
votes
2answers
94 views

How to insert lines into specific files in which a string is not present?

I'm looking for some help with a small script. I would like to search all files corresponding to /usr/local/directadmin/data/users/*/httpd.conf for the string centralized.log If the string is ...
2
votes
2answers
302 views

Sed command with apostrophe

sed -e 's/cluster_name: 'Test Cluster'/cluster_name: 'Test Cluster1'/' I have this error message: sed: -e expression, char 20: unterminated `s' command Please, how can i correct the sed command ...
2
votes
1answer
347 views

Recursive find-replace using sed with URLs

I have a large set of files in which I need to replace a full URL scheme. Some filenames contain spaces. After much searching and rial and error, this is the closest I've come: find /somedir -type f ...
0
votes
0answers
13 views

Mac OS X Find and Replace API

Are the Find and Replace operations under the Edit menu in Acrobat or Word simply a front end for the unix awk, sed or grep commands? Where can I find more information about what's going on underneath ...
0
votes
1answer
53 views

Edit file in-place without modifying line endings

I need to modify sources under Git version control. The sources are Visual Studio project files, which makes them native Microsoft. I want to avoid whitespace issues, including line ending games. I ...
1
vote
1answer
56 views

Remove invalid domain names with Sed

I'm having trouble writing a sed command do the following. I have a file that should only contain "valid" domain names. How I use with sed to remove any line that does not match an expression? The ...
0
votes
1answer
289 views

String replacement shell script on AIX

I am using AIX, and there is not an -i option available in the version of sed I am using: sed: illegal option -- i Usage: sed [-n] Script [File ...] sed [-n] [-e Script] ... [-f Script_file] ...
2
votes
1answer
40 views

Match first next word matching a given pattern using sed

I'm having trouble getting the following behaviour: input='somestring... --key1 val1 --key2 val2 --key3 val3 somestring...' output='val1' I tried using: echo $input | sed -nE 's/.*--key1 (.*) ...
0
votes
1answer
110 views

Remove version information from maven generated war file

I am trying to automate the deployment of war files that are generated by our build server using maven. I need to be able to extract the project name from the war filename so I can rename the file ...
0
votes
1answer
82 views

Piping a line of the file read with while read loop

I am trying to read each line of the file and then assign some parts of it to variables. A line itself is read as a variable so I need to process a variable input say for cat which seems to be ...
2
votes
1answer
207 views

Append text to first occurrence of a pattern using sed

Say there is a text file as below: Hello world types="" Mario types="Game" What I want to do is find the first occurrence of type="" and append with word "program". I need output as: Hello world ...
2
votes
3answers
203 views

Extract version string from filename

We have a list of filenames in file a.txt with their version string embedded in them. Eg: gson-2.1 xmlParserAPIs-2.4.0 acrobat-1.1 orai18n-mapping-12.1.0.2 jdbc-se2.0 eclipse-core-runtime-20070801 ...
0
votes
1answer
59 views

How can I make this SED command more portable?

I'm using the following sed command: cat version | sed -e 's/[0-9][0-9][0-9][0-9][0-9:M]*-[abp]/Ver\n/' Which normalizes like this: 4330M-p -> Ver<newline> This works fine with GNU ...
0
votes
0answers
100 views

Replace in file with Huge String (Argument list too long)

I have a file in which I want to replace a string with a huge string literal in the form "19209302","19209329" such 100 thousand of entries. I am using sed and I get "Argument list to long" error, ...
0
votes
1answer
128 views

How would I write this VIM command for `sed`?

I have a .csv with special characters that are wrecking an import I need to do. In VIM, I discovered away to remove the special characters with : :%s/\r//g This removes ^M from some of my broken ...
1
vote
2answers
202 views

Best way to increment numbers in one line in Linux [closed]

I have one line with lot of entries among which is also time. ('DEFAULT',17,NULL,'2014-07-14 10:30:00','Something','2014-07-14 06:30:00',1),('DEFAULT',26,NULL,'2014-07-14 ...
0
votes
0answers
198 views

Removing special characters (spaces, newlines, tabs) from a text file

I have a flat file (1252 ANSI-Latin 1 encoding) that I wrote out from querying a third party's SQL database that has within it extraneous characters. To make it easier to reformat, I am writing it ...
2
votes
2answers
146 views

How to remove string following a specific word

I am trying to remove string starting with a specific word in my manifest file. The file containing lines looks like: <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" ...