sed Questions

8

Solved

I'm trying to get trim off trailing decimal zeroes off a floating point number, but no luck so far. echo "3/2" | bc -l | sed s/0\{1,\}\$// 1.50000000000000000000 I was hoping to get 1.5 but some...
Akilahakili asked 4/5, 2015 at 15:21

3

Solved

I'm trying to add a column (with the content '0') to the middle of a pre-existing tab-delimited text file. I imagine sed or awk will do what I want. I've seen various solutions online that do appro...
Callimachus asked 14/8, 2012 at 10:45

5

Solved

I am using sed command to insert an xml element into the existing xml file. I have xml file as <Students> <student> <name>john</> <id>123</id> </studen...
Lacagnia asked 23/4, 2014 at 4:22

4

Solved

I have a file with 4 million of lines, every line ends with the char $, but I mistakenly add a new line after the the line delimiter while scraping a website, so right now it is looking like this: ...
Duckbill asked 13/3, 2014 at 0:16

2

Solved

I need to find in files (xml) date in this format 2021-06-25T21:17:51Z and replace them with this format 2021-06-25T21:17:51.001Z I thought about using regexp with sed but back references does not ...
Olympus asked 24/1, 2022 at 18:29

3

Solved

I want to change my PS1 in my .bashrc file. I've found a script using printf with %q directive to escape characters : #!/bin/bash STR=$(printf "%q" "PS1=\u@\h:\w\$ ") sed -i '/PS1/c\'"$STR" ~/.bas...
Hungary asked 26/9, 2014 at 22:8

7

Solved

I have a file with an identifier and a value: ABC123 111111 ABC123 111111 ABCDEF 333333 ABCDEF 111111 CCCCCC 333333 ABC123 222222 DEF123 444444 DEF123 444444 Both columns contain duplicate values,...
Irenairene asked 20/8, 2024 at 19:36

8

Solved

I have pattern like below hi hello hallo greetings salutations no more hello for you I am trying to replace all newlines with tab using the following command sed -e "s_/\n_/\t_g" but it's not...
Ecthyma asked 24/10, 2009 at 11:23

4

I have a text file and I want to remove all lines containing the words: facebook, youtube, google, amazon, dropbox, etc. I know to delete lines containing a string with sed: sed '/facebook/d' myf...
Feeder asked 11/6, 2013 at 17:14

5

Solved

I have nearly 200 files and I want to find lines that are common to all 200 files,the lines are like this: HISEQ1:105:C0A57ACXX:2:1101:10000:105587/1 HISEQ1:105:C0A57ACXX:2:1101:10000:105587/2 HIS...
Peaceful asked 13/2, 2020 at 14:15

7

Solved

I have three types of strings that I'd like to capitalize in a bash script. I figured sed/awk would be my best bet, but I'm not sure. What's the best way given the following requirements? single ...
Granvillegranvillebarker asked 3/8, 2012 at 21:14

9

Solved

I'm trying to do the opposite of this question, replacing Unix line endings with Windows line endings, so that I can use SQL Server bcp over samba to import the file. I have sed installed but not d...
Prearrange asked 5/10, 2009 at 18:30

5

Solved

I have written a Makefile which works fine; I am just posting the part of it under investigation: BUILD_PRINT = @echo -e "\e[1;34mBuilding $<\e[0m" COMPILE_cpp = $(CXX) $(CFLAGS) -o $@ -c $<...
Burnet asked 10/6, 2014 at 15:5

3

Solved

I have an entire directory structure with zip files. I would like to: Traverse the entire directory structure recursively grabbing all the zip files I would like to find a specific file "*myLostF...
Poaceous asked 8/5, 2015 at 15:41

8

Solved

For grep there's a fixed string option, -F (fgrep) to turn off regex interpretation of the search string. Is there a similar facility for sed? I couldn't find anything in the man. A recommendation ...
Dinge asked 9/11, 2010 at 11:45

22

Solved

I want to add a newline at the end of a file only if it doesn't exist. This is to prevent multiple newlines at the end of the file. I'm hoping to use sed. Here are the issues I'm having with my cur...
Bergius asked 10/4, 2012 at 2:1

5

Solved

Recently I rewrote my program to find English words that are made of chemical symbol abbreviations, for example "HErSHeY". I came up with this dynamic regex: grep -Pi "^($(paste -s -...
Hypsography asked 4/5, 2024 at 0:34

4

Solved

I'm trying to replace a single line in a file with a multiline string stored in a variable. I am able to get the correct result when printing to screen, but not if I want to do an in-place replacem...
Hindermost asked 25/9, 2014 at 14:25

4

Solved

I'm confused by the two concepts in sed: hold space and pattern space. Can someone help explain them? Here's a snippet of the manual: h H Copy/append pattern space to hold space. g G Copy/append...
Robena asked 11/10, 2012 at 6:46

5

Solved

I have the following bash script which repeats for each image found. It needs to iterated over all html, css and js files, and replace all occurrences of an image within that file. for image in a...
Halfandhalf asked 2/4, 2017 at 18:1

15

Solved

I have a Windows batch file I'm creating, but I have to ECHO a large complex string, so I'm having to put double quotes on either end. The problem is that the quotes are also being ECHOed to the fi...
Behnken asked 29/4, 2009 at 22:56

4

Solved

I need to make an automatic bump of package.json in jenkins, and really stuck with it. The following sed command works in a pipeline but it changes the second field, I need to change the third on...
Basel asked 2/4, 2018 at 14:44

9

Solved

I want to delete one or more specific line numbers from a file. How would I do this using sed?
Evidential asked 21/1, 2010 at 20:8

1

I'm using turbo feature called turbo prune which creates folder out with partial copy of my monorepo, but unfortunately that means that when running in GitHub Actions commands like turbo run ...
Titoism asked 16/4, 2024 at 3:13

9

Solved

I have a new Ubuntu 12.04 VPS. I am trying to write a setup script that completes an entire LAMP installation. Where I am having trouble is appending a line to the /etc/hosts file. My current hosts...
Dripdry asked 12/10, 2013 at 21:11

© 2022 - 2025 — McMap. All rights reserved.