file1: and file2: I need find match file2 in file1 and print whole file1 + second column of file2 So ouptut is: My solution is very slow in bash: I am prefer FASTER any bash or awk solution. Output can be modified, but need keep all the informations (order of column can be different). EDIT: Right now it looks…
Tag: sed
Match unknown substring with RegEx
How can I get an unknown substring with an regular expression? I know what’s before and after the wanted string but I don’t want the known part with in the result. Example text: I’m looking for ‘SOMETHINGHERE’ and ‘SOMETHINGELSE’ only. vocher_ and .db are always befor…
How To replace leading zero with spaces in linux?
i have text like this i want to the result like this i have been searching all over and get no result, please help Answer With gawk you can use gensub: Or same pattern with sed:
In bash got unwanted newlines after sed and cat >>
I’m trying to substitute some lines in /etc/hosts file with my script here: It searches e.g. for lines like and replaces the line (if it’s found) with a sed command to nothing, but adds afterwards e.g. to I’m having to do (?) this because my LAN network addresses are changing very often (exa…
Bash – delete rows from one file while iterating through rows from another file
I have two files. file.txt and delete.txt file.txt contains the following for ex.: delete.txt contains: I need to delete the rows from file.txt that are contained within delete.txt cat file.txt should result with: So far I’ve tried this with no luck: I don’t receive any error, it just doesn’…
Using sed with regex to replace text on OSX and Linux
I am trying to replace some strings inside a file with sed using Regular Expressions. To complicate the matter, this is being done inside a Makefile script that needs to work on both osx and linux. Specifically, within file.tex I want to replace with (xxx and yyy are just example text.) Note, xxx could contai…
Fastest way to extract pattern
What is the fastest way to extract a substring of interest from input such as the following? Desired output (i.e., the :-terminated string following the string MsgTrace(65/26) in this example): noop I tried the following, but without success: Answer grep by default returns the entire line when a match is foun…
Re-arranging lines after a pattern in a file according to a specific order
I have a large log file with the below format I have created a shell script that insert those values in the database in the same order val1, val2, val3 ,val4 The problem is that the files sometimes gets corrupted and the variables come in different order, like below for example: Using shell script, I want to …
Bash replacing text in file
I want to automate changes in a File. For example ;max_input_vars = to max_input_vars = 10000 in /etc/php5/cli/php.ini with a script. How can I do that? I know command sed will do something like that. Answer Try this command:
BASH / sed – not giving same output for simple sed commands
Box 1: uname -srm Box 2: uname -srm; cat /etc/debian_version BASH on box1 is: GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16) BASH on box2 is: GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) On both boxes, I’m have the following script: All commands are same. This is what I’m…