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

learn more… | top users | synonyms

0
votes
4answers
119 views

How to replace first n no. of occurrence of a string using sed and/or awk?

I got a file alphabet where a has multiple occurrence in a line. $ cat alphabet a b c d e f g h i j k a a l m n a p q r a s t u v w a x y z a k l q z where $ cat alphabet | grep -o a | wc -l 7 ...
0
votes
1answer
92 views

How to run regex find and replace using windows command line

I want to perform complex find and replace that I do with notepad++ using command line. I found many solutions from web but none of them matches my requirements. I have one file in which I want to ...
0
votes
1answer
60 views

Sed (or other) script to replace a character within the capture group

I'm attempting to convert Pandoc markup to Confluence wiki markup, I'm using markdown2confluence to do the bulk of the work. This works quite well except where I'm talking about CSS and FreeMarker ...
0
votes
1answer
71 views

mv in for loop : “when moving multiple files last argument must be a directory”

I try to rename few files, omitting the first n characters. In fact I want to remove the [ www.blabla.com ] prefix (18 chars). I'm on windows, using bash command on Git-bash. I've tried this ...
2
votes
1answer
48 views

Special equal character with sed from shell

My environment: I am working with the command interpreter on Windows. I use an sh.exe that came with some proprietary tools I have installed. I do not know the details of that sh.exe but here is ...
0
votes
2answers
40 views

Multi Find and Replace Html Code

I have a URL error across multiple html files that I need to find and replace. Currently my pages show: src="//https: and I need to find and replace all with: src="https: Does anyone know a way ...
0
votes
0answers
53 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
125 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
40 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
37 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
35 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
63 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
48 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
30 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
25 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
136 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
21 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
123 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
72 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
50 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
87 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
75 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
125 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
78 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
298 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
322 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
179 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
220 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
108 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
227 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
36 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
34 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
103 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
103 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
323 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
396 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
55 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
58 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
340 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
41 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
118 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
84 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
233 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
229 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 ...