Skip to content
Advertisement

Tag: sed

Search and Replace under linux?

I tried the following but not adding ” this example I want to replace FILENAME_LOGIN to ‘login.php’ Tried this: However, it gives me login.php not ‘login.php’ Thanks Answer You only need sed for this:

Shell script to edit and add a entry in file

Could any one help me to add entry at the end of the line. This is linux os. Below is the contents of the file /boot/grub2/grub.cfg I need to add entry at the end of the line “text1” and “text2”. after edit my file should look like: Answer With sed expression:

extract multiple blocks of text to a new file

I need help extracting blocks of information from a single text file into new files or some form where I can manipulate the data from each block. Example: I need to be able to display and/or manipulate the variables (which I can do if I can isolate the right one). I don’t mind writing each one of these blocks to

Sed/awk: Aligning words in a file

I have a file with the following structure: I want to add another item to the file, using sed or awk: etc. So my next item looks like this: The column values is jagged. How do I align my values to the left like for previous items? I can see 2 solutions here: To align the values while inserting them

sed fails with errors

I’m trying to replace the next string with sed in all the files in the current directory : (including apostrophe) ‘Control_Reports_Pg.C_Table_Title_Date’ with the string : timeofday()::varchar(250) I tried to escape the special characters ‘ ( ) with the command : The error I got : sed: -e expression #1, char 22: unknown command:_’ I read online that I dont need

Generate a report using awk

I have /etc/fstab entries on 100 servers and i’m trying to write a awk script to identify following. What i need is, first my awk script need to print the domain name, then it should print tools incorrectly mounted on store and is not valid, but kdump01 mounted correctly on kdump , ops mounted correctly on ops) How can i

Command works in terminal but not as alias in profile.d

I have a problem regarding an alias file in /etc/profile.d/. This isn’t anything important. I’m just interested why it isn’t working as expected. So basically I have the file 00-alias.sh at the path mentioned above and I wanted to make a shortcut which reads a specific line of a file. So this is my code: With that code I should

Running statistics on multiple lines in bash

I have multiple HTTP headers in one giant file, separated with one empty line. I have approximately 10,000,000 of headers separated with an empty line. If I want to discover trends, like header order, I want to do aggregate headers to a one-liner (how I can aggregate lines ending with an empty line and do that separately for all headers?):

how can i cut one line on two on a cat /ect/passwd?

I’m trying to write a command that shows all odd lines of /etc/passwd: I’ve tried: but it didn’t work Is there a different way to obtain the result? Answer The step syntax is a GNU extension. sed ‘n;d’ should be the portable version of your sed invocation.

Advertisement