I have a file with content like so – @1: 00001109 Each line is of the same format. I want the final output to be @1: 00 00 11 09. I used command in sed to introduce a space every 2 characters – sed ‘s/.{2}/& /g’. But that will give me spaces in the part before the colon too which
Tag: sed
How to add characters in word and replace it using sed command in linux
I have one requirement. I have one text file named as a.txt, which is having list of words – Now I have one another file named as b.txt , which is having content as Like this n of lines are there with different different words. Then I am writing script file – So after running script the output file of
Deleting the first row and replacing the first column data with the given data
I have the directories name like folder1,folder2,folder3….folder10. Inside each directory there are many text files with different names.And each text files contain a text row on the top and two columns of data that looks like as below Then what i want to do is== at first i want to remove completely the first row of all text files present
Remove ” and n using sed
How to replace the below text using sed or in any other method. I need to replace the above to be like Answer A or . needs to be escaped in regex pattern. You may use this sed: You may consider this awk to remove ” and n characters anywhere in the file:
how to edit a line having IPv4 address using sed command
I need to modify an ntp configuration file by adding some options to the line containing Ip addresses. I have been trying it for so long using sed command, but no able to modify the line unless i don’t know the IP addresses. Let say, i have few lines as, server 172.0.0.1 server 10.0.0.1 I need to add iburst option
How do i extract some particular words from each line?
The text file has many lines of these sort , i want to extract the words after /videos till .mp4 and the very last number ( shown in bold ) and output each filtered line in a separate file Lets say for example the text file content is .. The output should be Answer You may try the below regex:
list tables from mysql dump file with sed
I have situation where I need to extract tables list from mysql dump file. I tried that with sed but got this error what did I miss in my regexp? Answer Since you are using Linux, and you need to get all strings inside the first backticks after DROP TABLE, I’d suggest using grep with a PCRE regex like See
Changing contents of a tsx file through shell script
I have a requirement to change the contents of config.tsx file that contains values like: I want to change this content using a shell script and save the file. Changed content can look like: How can I do this? Answer This should work: The -i option will edit the file in place. If you first want to try the command
How to read a variable from file, modify and safe it to an other variale
What I want: There is a file /scripts/backup/config.cfg which contains variables. In my specific case the important ones are: Then there is a script /scripts/backup/performBackup.sh For a specific reason I want a part of the script do the following operations: read the value of the variable ROOTLOCATION add a (“/” and) timestamp (Date&Time) safe the new created value to BACKUPLOCATION
Deleting strings from text file
I have a txt file, like this: I only want to keep: I tried: It works, but can’t get rid of the date. Answer Although you might prefer to get rid of more whitespace with: