Questions tagged [sed]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
37 views

Use sed/awk to add specific text from one file to beginning of another file

I'm trying to use sed/awk to copy a range of text from the beginning of file1 to a specific line. Then add that output to the beginning of file 2 for a script I'm writing. The following command does ...
0
votes
2answers
16 views

Extracting data from text file by specific characters

I have a program that reads from a sensor and prints on stdout. The interesting data for me is just the X,Y and Z values: [2021-05-07 10:47:41.993] [info] Acceleromter (avrg 100): X=+6696.080 Y=-5577....
0
votes
2answers
52 views

awk Removing Double Quotes from CSV File Quoted Strings separated by comma

I have a csv file I would like to remove any rouge " or , in it. The problem is all my fields look something like this "***********","*********", where * = can be any ...
0
votes
0answers
17 views

MacOS script to search a text file for a partial string and add a line if found [closed]

New here, and I tried a search but managed to find a lot of SIMILAR things but not quite what I'm after. I'm looking for a shell or Applescript that will take a text file, search it for one of 3 ...
0
votes
2answers
33 views

(vim) How to remove word that has a specified character?

so I tried to remove any word that has a letter "a" in it with vim I want to change this string hotel echo lima lima oscar whiskey oscar romeo lima delta to hotel echo whiskey romeo I hope I ...
4
votes
1answer
171 views

Subshell won't work as indented

I have some files like this: ├── abc.conf ├── def.conf ├── xyz.conf ├── 10-abc.conf.postix ├── 10-def.conf.postix and I want to remove the .postfix from all files which starts with 10-. To do this ...
0
votes
0answers
18 views

sed for special charactersand begining and end of string?

sed -e 's/© some text with spaces., string (SS)/do_not_count/g' Yhis command does not work for my scenario neither is it giving any error. Basically, I need to get rid of © some text with spaces., ...
0
votes
1answer
20 views

Using wildcards to do mass copying to slightly different names

I want to copy many files inside a single directory. An example filename starts with error042021.mysite and I want the new name end with -dev.co.at.txt. I think I need a wildcard for the number, ...
0
votes
2answers
23 views

Auto-filling/bypassing SED password screen

I would like to use a Self-Encrypting Drive in an embedded Linux application, but since it is embedded (i.e. no monitor, keyboard, or mouse), I have no way to enter the password on boot. Is there a ...
1
vote
1answer
23 views

regex help: Replacing characters

I want to change characters in a json file. I tried some commands but didn't find a solution. Input: { "cpu" : 0.0789131391278358, "disk" : 0, "diskread"...
0
votes
1answer
19 views

Combining two txt files containing name and last name on command line

I have two text files. First file have 20 Names listed in seperate lines and 2nd file have 20 surnames listed in seperated lines. How I can combine those files. So final text file have both first name ...
0
votes
3answers
58 views

Can matched patterns be used in a replacement string?

I am new to both regular expressions and GNU sed. I have an anonymised sample of the data below. RED: 13905 16356 17457 18164 18447 21063 26924 27684 30111 30205 CERISE: 6221 6524 18250 24367 24462 ...
0
votes
1answer
39 views

Sed special characters in variable '&'

Sorry, easy question, but I can't find how to do it: I have a special char "&" in a Variables that I have to use in sed. Example: #The template .env cat .env MY_SECRET = VAR_MY_SECRET ...
13
votes
5answers
3k views

Add to every end of line in Notepad++

I have a long text file gallery-dl -g -i w4b027.txt > gallery-dl -g -i a4b028.txt > gallery-dl -g -i b4b029.txt > gallery-dl -g -i c4b030.txt > gallery-dl -g -i d4b031.txt > gallery-dl -...
0
votes
0answers
20 views

sed XML parse select text between tags with special characters while deleting other blocks

I am trying to parse an XML which consists of blocks between and , I am parsing within a do while loop , while reading the block between and , I am also redirecting the block to a file while ...
0
votes
1answer
50 views

sed pattern from file and substitute with new pattern in another file using string variables

I have several files where I have the following patterns: t= 9.90000 2 2 t= 10.00000 1 1 Now, the value of t (for example 100.00000) and also the value of (2 2) is ...
0
votes
0answers
18 views

I want to replace a name with special_character name using sed command?

before module name change module \${a ; endmodule after module name change module \${a_ext; endmodule Here, I want to replace any name using sed command , but the issue is when special_character name ...
0
votes
0answers
19 views

Iterating paste function?

I do a bunch of data entry, and one thing I find myself doing often across many sites/programs is: Fill field: "part_number1_todays_date_blah" Copy text entered Go to new page/file/line ...
0
votes
1answer
29 views

How to use sed's substitute with a regex pattern as variable?

Let us say that we have the following as stdin (as an example) Life is temporary I want sed to replace this with Life is permanent with a command somewhere along the lines of sed 's/Life<%XY=.*&...
2
votes
1answer
69 views

Shell special chars blowing up regexp(s) in all: sed, (g)awk, and perl [closed]

I would like to change the PS1 in my ~/.bashrc programmatically with any of the the most popular regexp tools { sed, awk or perl }. However, I have problems with special characters. Note that in the ...
2
votes
2answers
111 views

Filtering a CSV and adding a new tag column in powershell

I have a CSV-file in.txt with 3 columns (Doc_Title, Doc_Date, Doc_URL) and I want to use PS to add another column Doc_Category using another CSV-file tag.txt with 2 columns (keyword, tag). I already ...
1
vote
0answers
23 views

Removing multiple parts of a file name using cut

I have a bunch of files named like so: CI2_S1_20201120_S75_L001_R1_001.fastq.gz CI2_S2_20201120_S76_L001_R2_001.fastq.gz AV2_S2_20201120_S61_L001_R2_001.fastq.gz and I want to rename the files to ...
0
votes
1answer
32 views

Sed for windows not working after Powershell edit

I want to automate selecting data out of a pdf file for later processing in a spreadsheet. 1: Copy all text into a .txt file, using Notepad - ok. 2: Remove all newlines, CRLF, to create a single line ...
0
votes
1answer
20 views

How do I look for a word, which letters are seperated by spaces?

I want to grep over pdf files for specific search terms. I'm using pdfgrep for this task, which works quite fine. However, sometimes words are specified with spaces between each letter. E.g.: ...
1
vote
2answers
50 views

How to remove white space after parsing from JSON with sed

How can I remove any white space if any after parsing from JSON? whereami -r Parse result without sed. { "ip": "95.16.15.10", "country_code": "US", "...
1
vote
2answers
36 views

Insert third column using sed regex

I'm trying to insert a third column using sed, where the column separator is the bar character '|'. The problem is the total number of columns in the text is unknown but at least 2. For example, I ...
2
votes
2answers
198 views

Remove lines where either column is empty

I have a large colon-delimited text file containing two columns like this: valueA:valueB valueC: valueD:valueE :valueG If there is no data to the left or right of the colon, I want to remove the ...
3
votes
1answer
204 views

Remove spaces from first column of delimited file

I have a very large colon-delimited file with two columns: dhsj fdksjdk:dndkdlkfkd shfdosod dkjsosjd:dkj dosjeod dhswisoaidodisbw: dhsoi wjdos fjfdododjfideefkjso sn:fhfdkd dkdjdf If the first ...
0
votes
1answer
59 views

Cannot get result of sed pipe as argument for cd

I have a working echo + sed command echo %cd% | sed -E 's#(C\:\\\some\\\path\\\)([-_A-Za-z0-9]+).*#\1\2#g' I cannot get its result to work as cd argument (Windows, cmder) ~~=cd $(echo %cd% | sed -E '...
0
votes
1answer
40 views

How to fix sed command to work in groovy

I have the following code which works in gitlab (without the sh part): sh ''' mkdir ./pylint docker run --rm --entrypoint=/usr/local/bin/pylint ${IMAGE_NAME}:${IMAGE_VERSION} --rcfile=.pylintrc --exit-...
1
vote
1answer
93 views

sed, passing capturing group value to subcommand

Consider following example: echo abc=123 | sed "s/\([^=]*\)=\(.*\)/\1=\2/" outputs abc=123 ie. the same as input. We matched everything up until symbol = as capturing group 1, and ...
0
votes
0answers
32 views

How to edit file inplace

I am writing some logs in a file using logging module #filename : demo.py import logging #other imports as well logging.basicConfig(filename="myfile.log", format='%(...
0
votes
0answers
26 views

Not the same output of small bash-script on different Linux systems

I have a small script, that makes JOIN of LSBLK and DF commands. Script: lsblk -n -b --output KNAME,NAME,SIZE,MOUNTPOINT | egrep -v "fd0|ram|loop|sr0|hdc|cdrom|[SWAP]" | while read kname ...
0
votes
1answer
36 views

Helping with Join of output from DF and LSBLK Linux commands via bash

I already asked this question, but without update. I think this information should be related to this site. I need to merge two outputs in Linux. This: lsblk -n -b --output KNAME,NAME,SIZE,MOUNTPOINT |...
0
votes
0answers
30 views

Overwriting the first line of a file inplace

I want to change the first line of my file, with a new line shorter than the old one(for example change foo with bar). However even sed -i uses temp file (i thought about sed because the first line ...
1
vote
1answer
113 views

SED find and replace by keeping indentation

I can't seem to find an answer, I am trying to find and replace a text. For example, find newName: and replace it with a variable that expands. I tried: sed -i "/ newTag:/c newTag: $IMAGE_TAG&...
0
votes
1answer
25 views

Convert text framed with asterisks(**) to italic, using sed command in Linux

The requires are bellow: Convert text framed with asterisks to italic. Don't touch text in double asterisks (bold). Use sed command. For example, *italic* => <em>italic<\em> **not ...
1
vote
1answer
24 views

Replace text between '=' and '?' on all occurences in URL string

Given this string: https://example.com?a=1&b=2 I want to achieve the following: https://example.com?a=VALUE&b=VALUE This is how far I got: echo "https://example.com?a=1&b=2" | ...
0
votes
2answers
288 views

In bash, how can I replace empty lines with null and vice-versa?

How can I replace two newline characters \n\n with a null \0 character in bash, and vice-versa? I see that td can replace a single newline with null, but not two consecutive newline characters. I ...
0
votes
1answer
43 views

how do i use sed to replace an power expression in sv

I have used the below command to replace the "2**n" sed -i 's|2**n|n|g' ./file.sv and even used the below way too but getting an error sed -i 's|"2**n"|n|g' ./file.sv sed: -e ...
0
votes
1answer
64 views

Using sed to remove text between two characters

I am new at shell scripting and using sed and need help to remove text between two specified characters (not including the characters). I need to remove between > and = For example > hello the ...
1
vote
1answer
92 views

What does this sed command mean?

Can someone please help me interpret the following Linux Sed command? sed -i '' 's#__OPENGL_LIBS__#-lGL -lGLU#' src/qt-mbgrdviz-3/qt-mbgrdviz-3.pro I cheerfully admit that I find sed command syntax ...
0
votes
1answer
39 views

How would I use sed and/or awk/grep to edit the line following a matched string?

I have a large text file that needs some changes. I need to do this by first locating lines that have a particular common string, and then editing the line directly after that. So for example, if I ...
0
votes
0answers
35 views

How to recursively rename, sort and move incoming PDF files from subdirectories

I have a program that periodically downloads certain publications in PDF format as they become available, along with additional files (e.g. *.nfo), which I don't need. The program places the incoming ...
0
votes
2answers
42 views

How to decrypt octal encoding from zfs diff output?

zfs diff replaces some of the characters in files names with \xxxx (in an octal encoding). Can I decrypt it back with awk or sed or any other common utility (without resorting to a perl or a python ...
1
vote
0answers
35 views

How to take 2 characters of a string and remove everything until the next string using sed

I am trying to take the first 2 characters of the first word which would be "wo" and remove everything else and combine it with the second word. Example: worker1, 0001, company1 worker2, ...
0
votes
0answers
16 views

When piping sed command, output becomes all spaces

This is for a lab I have in a class, the professor has told me to use sed to remove all punctuation and double spacing by piping together several sed commands. When I pipe the commands together my ...
0
votes
1answer
28 views

how to use sed to substitute a string with another string starting with $?

I want to replace the content of a file cat test.sh attribute = "metaapp" so I am trying to replace the metaapp with string ${meta.app} with hep of sed using sed -i s/metaapp/${meta.app}/g ...
0
votes
1answer
27 views

cannot replace specific characters in stream edit

sed is such a wonderful tool, but for some reason I cannot make it do what I need this time. I'm working with huge datasets in csv. Some files are delimited with ;(semi colon) and others with ,(comma) ...
0
votes
0answers
24 views

What are the sed commands to Insert three lines of text after the line that matches?

I have three line of text such as the following: We don't \yet\ know \who\ will be the person to "represent" the \community\ at large They are to be inserted after the line Not in this ...

1
2 3 4 5
19