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

learn more… | top users | synonyms

-1
votes
1answer
35 views

Oneliner to get the list of filenames which have last line (or line on position X) matching certain pattern?

How to get the list of filenames which have last line (or line on position X) matching certain pattern? We are looking for oneliner.
0
votes
2answers
31 views

Unable to add spaces

How can i add spaces between my outputs using sed/echo or any other command in linux? Preferred Output: Virtual Machine Test01 status Running. Virtual Disk Test01 size 61GB Physical Disk ...
0
votes
1answer
176 views

How secure is BitLocker without a TPM, using SED?

I'm trying to find a source for some basic information about BitLocker. Say I have a self-encrypting drive (SED) like a Samsung EVO, but no TPM. I enable BitLocker. There are two options: Password ...
4
votes
3answers
156 views

How to append to the first line of a file?

How can you use sed to replace the entire first line of a file with that first line plus some additional text? For example, how can I append -foo to a file that contains only one line. testfile ...
0
votes
0answers
38 views

Sed command to replace NUL character in file

I am using the command sed -i 's/\o000//g' filename or sed -i 's/\x0//g' filename to remove the NUL character but the command works fine in DEV environment but doesnt work in UAT. OS and sed version ...
1
vote
1answer
39 views

Remove a certain part in a text file

I got the file, text.txt. In this file I have written: "test" "okay" I want to remove the " part of this file, how'd I do this?
2
votes
1answer
35 views

sed, regex replace with vars

I'm trying to use sed (4.2.2-4+b1 debian 8 (jessie)) to replace text in multiple files. To go from this: $var1 = array(foo=>"bar",bar=>"foo"); $var2 = array( foo=>"bar", bar=>"foo" ); $...
1
vote
2answers
112 views

Using Sed Ampersand Substitution with Array

I am trying to use the ampersand character of sed to replace with the original string, and then read from the array, but it is not working. I just get the error: 'operand expected (error token is "&...
0
votes
1answer
44 views

redirect ALL output from shell to a command to act as filter

How to redirect all std-output from bash to a command like 'grep' or 'sed' to filter the output and then write it to a file? This is what I want in principle: exec > >(cat | cat >>/tmp/...
0
votes
2answers
180 views

Rename CSV header using command line tools

Given a CSV file, h1 h2 h3 a b c z x b how to rename the first header to One and the third header to Three using command line tools, namely One h2 Three a b c z x b
0
votes
1answer
33 views

Transform CSV column by a function using command line tools

Given a csv file such as h1 h2 a 0 b 1 c 0 how to rename 0 to YES and 1 to NO in the second column.
1
vote
3answers
98 views

sed command in console works; but in shell script it throws error

I am trying to write a shell script to replace the SEARCH string by REPLACE string in all the files of the current directory (directory where my script remains). The condition I have is : the script ...
0
votes
1answer
29 views

Linux, how do I use sed to edit apostrophes?

So I need to edit a bunch of html files.. I've used sed before, in batch, but the problem I'm having is that my string of text to locate and replace both contain apostrophe's. While you can change ...
0
votes
3answers
47 views

combine xargs with sed to modify or change a a file

I'm searching the general pattern ***_23 on the end of a line ( but not: at_23) inside a file , and than I'm trying to change all those findings to \<23>, in the same source file ( insert function ...
0
votes
2answers
18 views

Ubuntu replace expression in dir and all sub directories

How can I replace an expresion that has a forward slash with another in all dirs and subdirs? I used this to find: grep -rnw "/var/www/site" -e "app/COD1" And now I want to replace: "app/COD1" with ...
0
votes
3answers
58 views

Substring in string in bash?

What is the equivalent of the python statement in bash: if "mystr" in "a long string with mystring in it": print("found string") The offset in number of characters can NOT be relied on to be ...
0
votes
1answer
27 views

A way to split a text file into arbitrary blocks based on first column?

I have a (very large) text file of the form... /folder1/fileA /folder1/fileB /folder1/fileC ... /folder999/fileA /folder999/fileB /folder999/fileC ...etc with an unknown number of entries for each ...
0
votes
2answers
108 views

sed command returning “sed: bad option in substitution expression”

For example:- I have a file named file.txt $ cat file.txt $key I have a environment variable, for eg: $key in a text file and lets say $key = 1234, so I can replace the value with the below ...
-1
votes
1answer
32 views

How to show a particular section from a line in linux?

Let's say I have a file with the following line: [{"name”:”10.0.0.1”,”address":"10.0.0.1”,”subscriptions["all"],"version":"0.0.0”,”timestamp":1450270166},{"name":"10.0.0.2","address":"10.0.0.2","...
3
votes
2answers
50 views

How to get command output of “nvidia-settings” via command line?

the case at hand: nvidia-settings -q all | grep 'Attribute.*GPUCoreTemp' gives: Attribute 'GPUCoreTemp' (system5:0.0) 58. Attribute 'GPUCoreTemp' (system5:0[gpu:0]): ...
0
votes
4answers
191 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
135 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
74 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
90 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
53 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
50 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
62 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
138 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
49 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
43 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
36 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
65 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 /web/...
1
vote
1answer
52 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 doesn'...
0
votes
1answer
31 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> <p>…<...
1
vote
1answer
30 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
172 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: chr1:66997824-67000456  ...
0
votes
1answer
22 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
140 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
73 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
61 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 git@github.com:acme-inc/repo0....
2
votes
2answers
106 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
42 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
84 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
173 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
95 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
420 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 's/open/'$...
0
votes
2answers
449 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
207 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
248 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/' ...