Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splitting unix output

Tags:

grep

unix

I'm trying to extract an address from a file.

grep keyword /path/to/file

is how I'm finding the line of code I want. The output is something like

var=http://address

Is there a way I can get only the part directly after the = i.e. http://address , considering the keyword I'm greping for is both in the var and http://address parts

like image 238
mskew Avatar asked Feb 01 '13 17:02

mskew


People also ask

How do you split in Unix?

The split command will give each output file it creates the name prefix with an extension tacked to the end that indicates its order. By default, the split command adds aa to the first output file, proceeding through the alphabet to zz for subsequent files. If you do not specify a prefix, most systems use x .

How do I split a single file into multiple files in Unix?

To split a file into pieces, you simply use the split command. By default, the split command uses a very simple naming scheme. The file chunks will be named xaa, xab, xac, etc., and, presumably, if you break up a file that is sufficiently large, you might even get chunks named xza and xzz.

How do you split a Unix file by pattern?

The command "csplit" can be used to split a file into different files based on certain pattern in the file or line numbers. we can split the file into two new files ,each having part of the contents of the original file, using csplit.

How do I split a field in Linux?

You must specify either the -c option to cut by column or -f to cut by fields. (Fields are separated by tabs unless you specify a different field separator with -d. Use quotes (Section 27.12) if you want a space or other special character as the delimiter.)


1 Answers

grep keyword /path/to/file | cut -d= -f2-
like image 112
Celada Avatar answered Oct 02 '22 07:10

Celada