Skip to main content

All Questions

6 votes
13 answers
2k views

UNIX command to add comma and space

I have a file that looks like $ cat IP 10.3.1.1 10.4.1.1 10.6.3.1 10.19.4.2 10.22.3.4 How do I make it look like: $ cat IP 10.3.1.1, 10.4.1.1, 10.6.3.1, 10.19.4.2, 10.22.3.4
Shahriar Flamneco's user avatar
0 votes
1 answer
836 views

Only perform sed operations on lines starting with a particular string [closed]

I have the following file format Received from +11231231234 at 2021-10-10T19:56:50-07:00: This is a message that contains words like from, at, etc. Sent to +11231231234 at 2021-10-11T06:50:57+00:00: ...
jf4i2d's user avatar
  • 73
0 votes
2 answers
317 views

How to create a sed script to replace quotes in a file? [duplicate]

So I manually use the following two commands in succession on my data file, i.e. I trigger the second command after the first has finished updating the file: sed -i 's/""""/" &...
BasicQs's user avatar
0 votes
1 answer
51 views

Query on updating a Config file

I am new to scripting and would need assistance in one of my requirement. I have a config file having below information Run=YES I want to update the value to "No" through script. Below is ...
Apsvj 's user avatar
-1 votes
1 answer
39 views

print the count and the line after search based on pattern

I have lines like this in multiple log files FILE 1: Line 203:Caused by :arithmatic overflow exception Line 204:at com.abc.java FILE 2: Line 105:Caused by : ???String out of bound exception Line ...
Sathish Kumar's user avatar
0 votes
1 answer
2k views

Need help in sed to replace text with empty space

How to replace below text with an empty line in a config file? # + : STANDANRD\ADMIN_USERS_ONLY : ALL
Harshita Reddy's user avatar
0 votes
1 answer
647 views

Replacing multiple lines with sed using a scriptfile (sed -f)

Based on the awesome answer found here, I'm trying to use some of these commands inside a sed scriptfile that will be called using sed -f. The file has multiple sed commands and it's been working ...
Felipe's user avatar
  • 101
1 vote
2 answers
79 views

Remove duplicates csv based on first value keeping the longest line between duplicates

I have many different csv files in a folder (megadrive.txt, snes.txt) like this: Aerial Assault (USA);Aerial Assault (USA);Sega Master System;;;;;;;;;0;;;;; Aerial Assault (USA);Aerial Assault (USA);...
Isabelle's user avatar
0 votes
3 answers
160 views

I wish to replace a string containing a pattern using sed

I have the following lines in a file named ref.list. 234 ./XYZ_SiteMetric_TIMESTAMP.dat 456 ./XYZ_Site_TIMESTAMP.dat I need to make them: 234 SiteMetric 456 Site I am using the ...
Mehul Verma's user avatar
2 votes
3 answers
2k views

How can I substitute a text that is inside single quotes on multiple lines using command-line tools?

I have a script that has a $variable storing a text with an undetermined number of lines. Let's say I've named it script.bash and it's located in $HOME: #!/bin/bash # commands on the beginning of my ...
Rafael Muynarsk's user avatar
2 votes
2 answers
8k views

How to search and replace for multiple words in one shot

I need to search and replace multiple words. For example, in my file, I want to search for any name of week days that appears with a comma after it: Sat, or Sun, or Mon, or Tue, or Wed, or Thur, or ...
qbq's user avatar
  • 59
1 vote
3 answers
63 views

Extracting text from a file when I know its format

I am running a script which will output a file called scServer.scs which looks something like this: [email protected] 2 Solution 1 Fluid Flow (Fluent) Solution ...
CFD-Tester's user avatar
-1 votes
3 answers
133 views

Json. How to add a sentence after : [closed]

The following is an extroct from a json file, that I have: }, { "name": "asdasd", "script": "dsad.js", "merge_logs": ture, "error_file": "/ofghfghgfh.log", "out_file": "/...
ortiga's user avatar
  • 131
0 votes
1 answer
1k views

How to replace an entire paragraph in a file?

I want to change this: ... %%%23begin aaaaaaa \\ bbbbbbb \\ ccccccc \\ %%%23end ... to this ... %%%23begin xxxxxxxx \\ yyyyyyyy \\ zzzzzzzzz \\ tttttttt \\ %%%23end ... the number of ...
Neo Mosaid's user avatar
0 votes
3 answers
1k views

How to add a new profile entry to Firefox's profiles.ini using a script?

Firefox uses a text file named ~/.mozilla/firefox/profiles.ini to hold a list of profiles. The entries look similar to this: [Profile0] Name=default IsRelative=1 Path=default Default=1 ... [...
MountainX's user avatar
  • 18.8k

15 30 50 per page