Category "sed"

use sed to replace version number in a package.json file

This is a part of my package.json file { "name": "org-team-module", "version": "1.1.0-snapshot", "description": "Some description", "scripts": {

Extract a string between double quotes from the 6th line of a file in Unix and assign it to variable

Newbie to unix/shell/bash. I have a file name CellSite whose 6th line is as below: btsName = "RV74XC038", I want to extract the string from 6th line that i

select subdomains using print command

cat a.txt a.b.c.d.e.google.com x.y.z.google.com rev a.txt | awk -F. '{print $2,$3}' | rev This is showing: e google x google But I want this output a.b.c.d.e

Convert sed command from linux to freebsd / macos

I have a very small script that someone here helped me with. It deletes all tracks that are under 1000bits. Works great under linux. Works as well under freebsd

Iterate over a csv and change the values of a column that meets a condition

I have to use bash to iterate over a CSV file and replace the values of a column that meets a condition. Finally, the results have to be stored in an output fil

jq replace part of value in json

I need to replace part of a value from a json output. I could easily do this using sed -i however it would also replace other parts of the file I don't want it

Change indented multiline string in file in terminal

i want to change multiline string within particular marks that is indented in file, example looks like this: non_important_array: [ text ], impo

Tool sed-like to insert a HTML snippet code (a div block) after a <div id="jsn-page">...</div>

I am looking for a way to insert a block <div id="jsn-content-bottom">...code...</div> after a block <div id="jsn-body">...</div>. I wan

Extract string between combination of words and characters [duplicate]

I would like to keep the strings between (FROM and as), and (From and newline character). Input: FROM some_registry as registry1 FROM another_

Replace same occurrence of word with different words using sed

I want to replace 2 same words in file(app.properties) with 2 different words using sed command. Example: mysql.host=<<CHANGE_ME>> mysql.username=te

Count 3 types of delimiters (comma, semicolon, pipe) from different files

I am trying to develop the similar thing. But my requirement is little bit different. I would like to count the number of delimiters in the 1st row and the 2nd

Finding second highest salary using awk

I have a file as follows 1 rob hr 10000 2 charls it 20000 4 kk Fin 30000 5 km it 30000 6 kl it 30000 7 mark hr 10000 8 kc it 30000 9 dc fin 40000 10 m

How to replace "00" in data with "N/A" skipping first row in sed?

I'm working with GWAS data, My data looks like this: IID,kgp11004425,rs11274005,kgp183005,rs746410036,kgp7979600 1,00,AG,GT,AK,00 32,AG,GG,AA,00,AT 300,TT,AA,00

What is the difference between p and P in sed?

Can anyone explain what is the difference between p and P in Sed? Suppose I want to print lines containing gmail in the below file using both p and P give the

Parsing HTML on the command line; How to capture text in <strong></strong>?

I'm trying to grab data from HTML output that looks like this: <strong>Target1NoSpaces</strong><span class="creator"> .... <strong>Targ

Using sed to replace tab with spaces

I'm trying to replace the tab with 4 spaces, using sed, but it is not working. Here is my code: sed -i '{s/\t/ \{4\}/g}' filename Any suggestion is apprecia

Prefix the contents of a file using content of another file having a single line

I am trying to insert the contents of a file1.txt into file2.txt using sed. The content of file1.txt is just a single line, which is a path. I want it to be add

How to use sed to remove the last n lines of a file

I want to remove some n lines from the end of a file. Can this be done using sed? For example, to remove lines from 2 to 4, I can use $ sed '2,4d' file But

How to use sed/grep to extract text between two words?

I am trying to output a string that contains everything between two words of a string: input: "Here is a String" output: "is a" Using: sed -n '/Here/,/

How do i replace [] brackets using SED

I have a string that i am want to remove punctuation from. I started with sed 's/[[:punct:]]/ /g' But i had problems on HP-UX not liking that all the time