People who code: we want your input. Take the Survey

Questions tagged [sed]

Sed stands for Stream EDitor - one of the basic tools in the POSIX environment. It processes one or more files according to an editing script and writes the results to standard output. Created in Bell Labs, it has been around since mid-70s.

Filter by
Sorted by
Tagged with
0
votes
1answer
35 views

SED config-file with single quote

I have a config file which looks like this: $this->db_host = 'localhost'; $this->db_port = '3306'; $this->db_name = 'database'; $this->db_user = 'root'; Im ...
0
votes
1answer
32 views

“grep” a group of lines

I am reviewing my mail traffic looking for large messages and sending these "finds" to the staff for removal or approval. Each message has four SMTP lines and I want extract just these ...
0
votes
2answers
50 views

Piping nc to sed and evaluate datetime for each row

Could someone provide any idea, how could i pipe data from nc to sed (or awk, or anything) and evaluate and write to file a timestamp after each row? What i have: # cat /etc/systemd/system/ncserver....
-1
votes
1answer
50 views

sed linux replace complex link

I am having this challenge to pass a link from a variable: InstallLocation=/opt/software/software.properties ReplaceeVar=http://localhost:1234/ab/cd/{company}/{employee}/ sed -i "s/...
0
votes
0answers
23 views

Finding a string and remove all contents between two delimiters

I have searched and I don't know what I'm doing wrong but I can't find an answer to this question. I have a file with all text stored as a single line. I am needing to find a pattern and remove all ...
0
votes
0answers
31 views

which are the ways to find new files in a server location

I'm trying to find new file(s) created , copied, moved or modified in latest hour in a linux server location /home/user/ and I would know if the following command is the best way which covers all ...
0
votes
1answer
22 views

Multiply first column by variable depending on unit

I have du -sh output saved to txt file: 2.1G /home/x/sample/2GB/ 101M /home/x/sample/100MB/ ... What I want is to multiply each value in the first column by a value taken from variable ...
0
votes
0answers
16 views

Find all words after specific string

So, here's the thing. I have a file contains like this: LOG=123 HEY=BRO FOO=BAR LOG=124 I need the value of LOG= and an output like this: 123 124 I already tried using this command: echo "$LOG&...
-2
votes
2answers
149 views

Linux Bash Scripting using grep sed and cut command to display ip address with port number

Can any one please help me I need a output of "192.168.1.1#53" by using these 'grep' 'sed' and 'cut' command mandatory in linux bash scipting in given below text. ;; Query time: 29 msec ;; ...
-1
votes
1answer
91 views

Mac sed not the same as linux

I have a bash script that I have used before on Linux and it runs fine on different distros, but not on a MAC. I am trying to read a file and then delete the current line. For some reason on Mac I ...
1
vote
1answer
310 views

Escape characters in systemd ExecStart fail

I have the following snippet to extract a value from a jenkins server jnlp config file. It works out of the box in the terminal but not as a unit. I want a unit so I can put the value somewhere and ...
0
votes
1answer
61 views

Shell script to remove quotes when using SED

I'm trying to change a line of syntax in a config file where the line looks like the following: host="192.0.2.100" I'm writing a script that would require input the user to change the ip ...
0
votes
0answers
24 views

Summarize first column same field

I have some datas with URL's and used network data. I made a custom file with these data's and i stuck last one step. What i have now: sevroland.api.url.com 488 www.logstach.url.com 42725 ...
0
votes
1answer
171 views

How to change one line of code in a block of code from linux command line?

I have a change I need to make across multiple different sites and may need to make again in the future, so I'd like to put it in a shell script. Essentially I want to find a specific class block in a ...
0
votes
1answer
209 views

Issue restarting apache with cron / crontab ( Ubuntu 18.04)

I have a specific case where testing a new version of the software is being done at a specific time of the day so I have cronjob that should: Software is set in /var/www/html folders V2 and V3 ...
1
vote
2answers
38 views

Unix Sed time range parsing issue

I have Hybris SAP application with console log. The log format looks like this INFO | jvm 1 | main | 2020/05/28 17:17:19.969 | <String>timestamp</String> INFO | jvm 1 | ...
0
votes
1answer
115 views

Using sed command to replace config file with comment in linux terminal

I know a little about sed. In /etc/nanorc I got bunch of settings with comments (eg:). #bind ^K setting 1 #bind ^F whereis all #bind ^J setting 3 So, I want to comment out only this setting to ...
2
votes
2answers
66 views

Extract missing paths from bash array of paths [closed]

I have an array of paths: paths=( /foo/exists1 /foo/exists2 /foo/missing1 ) To find those that are missing: ls "${paths[@]}" 1>/dev/null Shows: ls: cannot access '/foo/missing1': No ...
0
votes
1answer
477 views

Have sed -i output to stdout the way just sed does

When I am running sed operations on a file, for example: sed 's/this/that/' /my/file.txt The output is displayed on stdout. However, when I apply the changes in place with -i there is no stdout (...
1
vote
1answer
101 views

mask public IP addresses from any command output (for diagnostic)

I'm writing a script to extract information from BusyBox v1.25.1/Linux 2.6.36/router where the user can simply run the script and copy/paste the output into a submission form to request support. The ...
0
votes
1answer
18 views

Use sed to strip out multiple cases with varying names

I have an ansible inventory that I need to remove all cases that start with site2-. For example I have a list that includes groups named: [site2-static-web] site2-ansible site2-accounts site2-admin ...
0
votes
2answers
478 views

How do I cut just the file name from from ls -l output? [closed]

I am in the process of concatenating ogg audio files in bulk with the help of ffmpeg using a mylist.txt file The format of the mylist.txt file is file '/path/to/file1.wav' file '/path/to/file2.wav' ...
1
vote
1answer
5k views

How to use Ansible modules replace or inline instead shell command with SED

i have file with string: MYAPP.db.username.DEV=MYUSERNAME Where: MYAPP mean name of applications DEV means environment MYUSERNAME means name of user for connection to db I need to replace these ...
0
votes
1answer
129 views

Convert date and time from output

I have a file with date and time on a couple thousand lines. I need to convert: 2019/08/02-01:23:50+0000 To: 02/Aug/2019-01:23:50 +0000 I so far have th=`grep ...
0
votes
1answer
68 views

Convert date format in file

I have a file with the current date format 11.22.33.44 - - [2019/08/02-01:23:50+0000] GET www. 1111:2222:3333:4444:5555:6666:7777:8888 - - [2019/08/02-01:28:18+0000] GET www. And i need to convert ...
0
votes
2answers
164 views

Parse Date from Text String in a 3 column format

I am given an array of lines from a text file. They look similar to this, and will always be structured like this: Full Tue Aug 27 10:59:43 2019 1 ...
3
votes
2answers
7k views

How to make in SSH private key from one line, three lines [closed]

i have ssh-key, something like this -----BEGIN RSA PRIVATE KEY----- my_super_secret_password -----END RSA PRIVATE KEY----- Of course this key does not work. When i am doing manual things, something, ...
2
votes
2answers
1k views

How to add the filename as prefix to each line of the text file? (batch processing; subdirectories)

I have many .txt files with their filenames being different dates: 01.01.2010.txt 02.01.2010.txt ... Currently each file (e.g.: 01.01.2010.txt) looks like this: 0.351 XXX XXX XXX XXX 0.292 ...
2
votes
2answers
153 views

sed insert a string into a matched line inside quoutes

I'm writing a shell script that modifies GRUB options: sed "/^GRUB_CMDLINE_LINUX_DEFAULT=/ s/$/ mem_sleep_default=deep /" /etc/default/grub This sed command matches the line ...
0
votes
2answers
41 views

sed/awk - find match by one string and change different string on the same line

this should be easy question for most of you but for me. I need to perform some text operations above json a yml config files, which contains definitions of some channels - structure of every line is ...
1
vote
1answer
528 views

remove single quote from all directory and file names

I ran a sed command recently and I mistyped the command (yes it happens). So now i have directory and file names that look like 'Call of Duty'. How can I recursively go back and rename all files and ...
-1
votes
2answers
118 views

get string inside quotes with sed

I have a file with text like these: "id":1519539,"description":"xxxxxxxx","severity":"yyy","pasahelpdesk":null,"subSource":"","dateReception":{"timezone":{"name":"Europe\/France","timestamp":...
0
votes
2answers
47 views

Extract text between 2 strings only if another string is present

I have a quit large XML file that I am trying to modify only certain lines of the file. The lines I want to modify will all contain in them. On those lines, I want to have only the text between 2 ...
0
votes
2answers
382 views

Delete a log while is written using SED - /var/log/messages

I had a filesystem that was over 60%. I found that the file /var/log/messages had more than 4 million lines so I decided to delete 2 million lines in order to clear some space. I executed the command ...
2
votes
1answer
44 views

How to stop sed from breaking when in combination with apg?

I am writing a script that will install WordPress automatically for me, to make my life easier as I have to deploy WordPress installs constantly. However, I am trying to make it so I never have to ...
0
votes
1answer
29 views

Update all Python files via Linux command

In my original Python files I have the following: from official.utils.flags import _base I need to change it to: from utils.flags import _base My file structure looks like this: . ├── README.md ├─...
0
votes
2answers
203 views

SED to search for and delete ip with a partial match

I have various bash scripts that run, they scan log files for folks who try and make mischief, spam us and so on. I have been struggling with this for some days trying to figure this out. I have a ...
0
votes
2answers
174 views

Adding a new line from file using sed

i'm trying to add a new line with data from a file to another file. The problem is, the data in the source file is with whitespaces so i do not get everything included. Here's my code: Source File: ...
1
vote
3answers
102 views

How to compress spaces in bash command output?

I work on a small screen and I'm trying to make the output of this command shorter, but I cannot get it to work. Command: docker container ls --all Output (too wide!): CONTAINER ID IMAGE ...
0
votes
1answer
320 views

Using sed to remove "(double-quotes) on code lines while leaving them on real comments in a vimrc [closed]

I'm finally learning how to use sed to edit configs while installing Ubuntu(Server/Desktop). After much gnashing of teeth and searching about for the proper syntax to not remove the "(comment double-...
1
vote
2answers
163 views

sed removing line breaks tail

In my Python script I needed a fast/efficient way to set a max filesize on a file I'm constantly writing to. Rather than bring the whole thing into py's RAM, I ran this shell command: sed -i '1d' ...
0
votes
1answer
36 views

delete some char set from the last column linux

I want to the delete everything after hyphen "e-" in the last column output.. Below is what my output looks like.. # awk '/out: OpenSSL/ { gsub( /[][]|out:/ , "" ) ; print $1,$2,$3 }' sslcheck.log |...
0
votes
0answers
699 views

sed + delete duplicate lines except the first one according to specific request

in /etc/services file I can see duplicate lines for example the following line is duplicate ( or more ) odasrv 2432/udp so it can easily deleted by sed as the follwing sed -i '/codasrv ...
1
vote
1answer
120 views

using sed to remove character at the end of numeric string

Here's a sample of my source file: USC00020958 -7777S 656S 721S 803S 891S 975S 972S 941S 906S 809S 695S 605S USC00021001 378S 389R 448R 522R 628R 736S ...
1
vote
3answers
59 views

Sed or other script, and regexp solution for cutting a filename

What I need is to get 2-3 variable from filenames. I use: FILES=$(ls -tr .../Files/) for f in $FILES; do ...... The files look like this: [letters and/or numbers and (underscore or nothing)][6 ...
-2
votes
1answer
35 views

sed search and add some sting

======KVM 虚拟化手册====== =====简介===== =====安装和配置kvm虚拟化===== ====检查是否支持KVM==== ====安装kvm虚拟化平台==== ====配置nested virtualization==== ==== 配置网络==== ====重启系统并检查相关配置==== =====virsh创建 & 安装虚拟机===== ====...
2
votes
4answers
1k views

Find and replace string between two delimiters

How do I replace a string between two delimiters? Some of the answers I found are close, but I think my need is a little more complex. I.e. smb.conf contains a blank line between shares. I want to ...
1
vote
2answers
101 views

HKPK Public Key Pinning - Auto add bash script

I recently started using HKPK Public Key Pinning. I have an automated script that generates my csr, certificate, and installs into apache2 on opensuse leap 42.3 I'm looking for a way to add spki ...
0
votes
1answer
84 views

sed for replacing non-commented lines in file

I have searched and have found well-informed answers that I think should work, but I can't get them to work. The problem is that I clearly so don't understand sed and all of the slashes and what any ...
0
votes
2answers
2k views

SED on Bash Script : how to replace text with special character that come from variable on Bash script

first, there is a variable that contain special character on bash script. here is the example. list.txt : user = root password = 1234 Bash Script : #!/bin/sh var1 = var&2018+& find . -name "...

1
2 3 4 5 6