Questions tagged [sed]
"sed" ("stream editor") is a Unix utility that parses and transforms text files.
1,047
questions
-1
votes
0
answers
23
views
When awk becomes too cumbersome, what is the next tool to consider to deal with text transformation? [closed]
Awk is invaluable for many purposes where text filter logic spans multiple lines and you need to maintain state (unlike grep and sed), but as I'm finding lately there may be cases where you need ...
1
vote
1
answer
44
views
How to Preend or Append File Name to Reflect Number of Pages in PDF using "qpdf" and "perl"
I am running the script at the bottom as a one-liner but have expanded for ease of reading.
Assume the directory contains the following file: File (11).pdf.
When the script executes, it simply repeats ...
1
vote
1
answer
116
views
Using sed to edit filepath variable
I am trying to use the sed command to edit a value in the .git/config file. When running the remote origin command, the config file creates the line of text like this":
url = https://github.com/...
1
vote
1
answer
95
views
How to merge all mp3 files located in the same directory?
The command below used to work but stopped around ubuntu/kubuntu 20.04.
ls *.mp3 | sed -e "s/\(.*\)/file '\1'/" | ffmpeg -protocol_whitelist 'file,pipe' -f concat -i - -c copy output.mp3
...
0
votes
2
answers
105
views
bash + how to insert date before line
lets say I want to pipe the date output in the beggining of some text
for example
echo "this line is test line" | date
and expected output should be
Wed May 22 14:55:10 UTC 2024 this line ...
0
votes
1
answer
33
views
sed does not consume rest of the line
I have one line of different words stored in a txt file
N/A 9.0 Yes Yes N/A N/A N/A N/A 8.8 Yes Yes N/A N/A N/A N/A 8.7 Yes Yes N/A N/A N/A N/A 9.2 Yes Yes Yes Yes Yes Yes 9.1 Yes Yes Yes Yes Yes Yes ...
-1
votes
1
answer
81
views
Search and replace doesn't work with sed busybox. getting sed: unmatched '/' error
I am trying to search a particular string and replace all occurrences within a file.
sed -i -e "s/$search_string/$replace_string/g" $filePath
I keep getting sed: unmatched '/'error on ...
0
votes
0
answers
46
views
Why did sed stop working with emoji overnight, but only on 1 of 3 machines?
I have 3 machine all running the same version of sed (cygwin), under TCC command line.
This morning, I woke up to sed failing to work with emoji, but only on 1 of the 3 machines.
The sed version is ...
0
votes
2
answers
95
views
sed search replace regexp pattern to replace repeated strings in paths
I'm having some trouble using sed to replace a particular repeated portion of a file path, and I cannot for the life of me figure out how to get it to work.
For example, say I have a list of file ...
0
votes
0
answers
29
views
rstrip On Lines of text being piped through sed s
So I am trying to implement the rstrip function on lines of text being piped into sed s and am having troubles. This is what I have that I think should work:
cat file1.txt | sed 's/[[:blank:]]+$//g;' &...
0
votes
2
answers
83
views
Find and replace date with UTC date
I have file that looks like this:
[2024-01-20 15:23:00] hello world
[2024-01-20 15:42:00] bye
[2024-01-20 15:43:00] foo bar
...
Date in this file are in UTC+1 and I want to convert in to UTC
I tried ...
0
votes
1
answer
94
views
why in spite of increasing the physical size of my text file its .gz compressed size shows significant decrease in size
I have a large test file which its .gz format is about 13 GB. I have replaced a substring in the original file and compressed the file to .gz format.
To do so, I used the following Linux command:
zcat ...
0
votes
1
answer
47
views
How do I tell sed to stop trying to process commands?
Maybe I'm an idiot (this is the likely scenario, and I'm new to sed/bash scripting), but why does this work:
NewVersion="$(echo $NewVersionFile | sed 's/^.*-\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/')&...
0
votes
3
answers
41
views
What's the history on the option separator of GNU sed?
They say GNU sed supports using any character following the command character as a separator for command options, like the following.
echo abc | sed 'y%abc%ABC%'
But I can't find the documentation ...
0
votes
1
answer
68
views
AWK replace some special new line to one line
i have some log like this:
2023-11-15T08:59:28.000000+00:00 database-1 # Time: 231115 8:59:28
# User@Host: rdsadmin[rdsadmin] @ localhost []
# Thread_id: 3 Schema: QC_hit: No
# Query_time: 0....