Skip to main content

Questions tagged [sed]

sed is a command-line stream editor for filtering and transforming text.

0 votes
0 answers
26 views

Writing to HTML file at a specific part using php

I am trying to write to a specific part of a HTML file using PHP with sed or awk or any other way. I want to add some text before </article> The following code I have does not work exec(“sed -i ‘...
Detonator120's user avatar
-1 votes
3 answers
90 views

Delete 2-line paragraphs, keep 3-line paragraphs, maintain newline between all

On a Linux machine with GNU tools I have an ascii file that consists of only 2-line and 3-line paragraphs, each paragraph separated by a newline. All 2-line paragraphs are to be deleted so that all 3-...
stampeder's user avatar
1 vote
2 answers
60 views

Use sed to insert a character in an xml file

I have an xml file with content following this format: <type:color>000000</type:color> <type:color>FFFFFF</type:color> The information within the tags are hex colors (many ...
jon danniken's user avatar
2 votes
2 answers
852 views

What does '\($*\)' mean in sed regular expression in a makefile?

I encounter the following sed command in make's manual. sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' And it has the following effect (this is an example in the manual): main.o : main.c defs.h # is turned into:...
liginity's user avatar
  • 143
1 vote
2 answers
58 views

Need to make multiple multiline replacements in file

I have a file with multiple "paragraphs" like this: <type>TRANS</type> <attributes/> <specification_method>rep_name</specification_method> <trans_object_id/&...
Todd Porter's user avatar
2 votes
4 answers
141 views

Sed command listing all lines between pattern including the final line

I have a file similar to below. [object_category=file] filesystem = enabled [object_category=registry] registry = enabled [privilege_id=SeAuditPrivilege] audit = enabled [privilege_id=...
ranjit abraham's user avatar
0 votes
3 answers
34 views

Convert timestamp to new format using SED

I have a giant .md file with a series of entries that represent the date like so: [2024/06/10 10:03 PM] However, I need to alter all of these so they now appear like so: 20240610. Thinking through ...
Linter's user avatar
  • 159
0 votes
0 answers
56 views

cleaning up full directories at once

right now, i have a filesystem that fills up fairly regularly. the TL;DR is that I can't introduce better log rotation, and the files must be deleted regularly. let's say i have the following output ...
Britton Harsch's user avatar
3 votes
4 answers
562 views

Cut and replace Nth character on every row

I have predictable piped input, I want to iterate over each row and change two characters. the character positions are 19 and 20 (on every row.) The 19th character is a comma, I want to cut that. The ...
XJMZX's user avatar
  • 75
-2 votes
1 answer
61 views

regular single column data to multiple rows

source data KKK-SNMImsi: 444444 KKK-SNMUserProfileId: KKK-SNMDefaultAutomaticProfile KKK-SNMMmeAddress: TDSGSN01 KKK-SNMMsisdn: 44235682436 KKK-SNMLocationState: LOCATED KKK-SNMRoamingAllowed: FALSE ...
Peter Cherop's user avatar
16 votes
5 answers
1k views

How can UserA programmatically replace a text string within a file they own that's located in /etc?

A non-root linux user owns a text file that's located in /etc, where the non-root linux user does not have permission to create files. The non-root linux user can edit the file manually via vi without ...
Tortoise Pirate's user avatar
2 votes
1 answer
88 views

Proxy between UNIX socket with socat

I used socal to create a proxy server between 2 UNIX sockets: /var/a.sock , /var/b.sock client -> /var/a.sock -> MY_COMMAND -> /var/b.sock -> MY_COMMAND -> /var/a.sock ->client. The ...
Polo1990's user avatar
1 vote
3 answers
73 views

Bash: sum a number present in N lines before a given pattern

I have a kdenlive project file (which is basically a xml file) with a lot of text clips inside. I need to bulk edit the x coordinate of a certain text that appears multiple times. This is an example: ...
baiserekku's user avatar
2 votes
2 answers
90 views

sed in conjuction with xargs and grep not working

I'm trying to change a string in multiple text files (configurations migrated to other user). I used this command: grep -iIlr "/home/user/.local" | xargs sed -i 's/\/home\/user\/\.local/~\/\....
Krackout's user avatar
  • 2,742
0 votes
3 answers
81 views

Extract YouTube video IDs from the end of filenames

I downloaded some files from YouTube a while back with the YouTube IDs in their names. My problem is that some IDs contain a character that also marks the beginning of the ID itself. $ ls *.mp4 | head ...
Joshua Briefman's user avatar

15 30 50 per page
1
2 3 4 5
489