Skip to content
Advertisement

Tag: sed

Faster solution to compare files in bash

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 like

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 before and after the relevant part but should not be in the result. A working

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 (exactly: at each working day, but not always

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 contain any letters, numbers, and _

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 found on a given input line. While option -o restricts

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 trying to do: On box1: When I’m running the script with arguments: aa1, aa3,aa2 aa1 ,

Advertisement