Sed (Stream EDitor) is a command line editor for POSIX environment. Sed processes one or more files according to an editing script and writes the results to standard output. Created at Bell Labs, it has been around since the mid-70s. Use this tag only if your question relates to programming using ...
0
votes
1answer
29 views
Sed Replace return error
find ./ -type f -exec sed -i -e ’s/var\/www\/html/var\/www\/this_new_html/g’ {} \;
I tried to run the above to replace all my file that have the following
include_once '/var/www/html/inc/functions....
1
vote
3answers
38 views
Filter file with findstr or awk and sed
I am trying to filter this file based on the backslash before a semicolon, for example filter the file below to obtain the lines that contain up to six backslashes before a semicolon
\\...
0
votes
1answer
36 views
How do I capture the last column with sed?
I know this is easy with awk ('{print $NF}'), but for learning purposes I'd like to understand how to do it with sed.
I have a variable with a bunch of white-space separated values, and I'd like to ...
1
vote
1answer
19 views
How to pass environment variable to a command passed to xmllint?
I'm trying to extract the db element's value attributes from an xml file using xmllint
My XPath Query needs to navigate to the correct dbtype, which I wish to store in an environment variable
...
-1
votes
0answers
58 views
Concatetating awk variables or sed variables
#!/bin/bash
domain="$(sed -n 's/^domain://p' file.txt)"
address1="$(sed -n 's/^address1://p' file.txt)"
Organisation1="$(sed -n 's/^Organisation1://p' file.txt)"
phone1="$(sed -n 's/^phone1://p' file....
0
votes
1answer
30 views
Replace string in a database file with an input file list - Terminal
I'd like to replace some file extension in an SQL file when I match strings from an input file using terminal.
I have an input.txt containing a list of file paths.
/2014/02/haru-...
0
votes
2answers
41 views
Linux Substitution: Add spaces between brackets in a file using sed
I would like to add spaces between my braces when there is content in the brackets. For example, I would like to substitute the following line
sorted ([] if interfaces is None else list(interfaces[...
-4
votes
2answers
58 views
Match the string between two braces & comment the lines between the braces [on hold]
We would like to match the string sysstat & comment all the lines within the flower bracket which match the string sysstat.It shouldn't affect the other flower brackets if it doesn't match the ...
2
votes
2answers
46 views
Remove 4 chars before the last char with sed (or awk)
I would like to remove the 4 chars before the last char.
Input:
abc2a982
e1kei9e5bc5
e1edeaww58476
Expected output:
abc2
e1kei95
e1edeaww6
So far I have tried:
cat file | while read line; do ...
0
votes
1answer
27 views
Replace “?*” with “*” but not “?+” with “*+”
I have the following string in a file:
?*TEST?*
?+
Now i want the ?* to be replaced with an asterisks *. The file should be like that after the replacement:
*TEST*
?+
I tested a few ways but ...
0
votes
2answers
33 views
Extract filename from multiple lines in unix
I'm trying to extract the name of the file name that has been generated by a Java program. This Java program spits out multiple lines and I know exactly what the format of the file name is going to be....
1
vote
2answers
42 views
Replacing $ with \$ in string variable
I my bash script, I have a string variable with a $ sign it, and the it isn't escaped. It looks like this:
x="hello $world"
Obviously, when I echo "$x", the output is hello, since $world is being ...
-1
votes
1answer
12 views
Replace word from multiple filenames
I have this filename:
BG60UFL-GBR_EarlsdonMSIN_2017-12-18_22-19-44-785_APPROACH.jpg
It needs to be replaced with whis:
BG60UFL-GBR__2017-12-18_22-19-44-785.jpg
This is what I tried:
sed 's#\\...
0
votes
2answers
47 views
sed: How to back reference one instance of sequence
I have input as sequence of floating points:
0.44491 0.068512 0.00086731 0.19827 0.10896 0.00021067
Now I wrote the regex as 's/\(\([[:digit:]]\+.[[:digit:]]\+\)[[:space:]]\+\)\{6\}/\2/p'...
0
votes
2answers
32 views
Difficulties in getting data between two strings in bash script
signature:
0000 - 70 59 90 77 3b da 12 b5-94 7d ca 72 77 ee 5d pY.w;....}.rw.]
000f - 1f a6 6b 17 60 58 4b a3-09 83 55 f5 58 36 80 ..k.`XK...U.X6.
001e - 1d b8 40 6e d9 95 77 27-...