Sponsored Content
Top Forums Shell Programming and Scripting regex matches from lines in file Post 302596747 by daWonderer on Wednesday 8th of February 2012 08:02:43 AM
Old 02-08-2012
for example there are columns for location, time and name in the file
the result should just contain time + name or just the names

LOC TIME NAME
nyc 10:30 Roger
la 06:45 Peter

EDIT:

guess I can use awk for this problem.. I'm now reading a tutorial about this..

Last edited by daWonderer; 02-08-2012 at 09:13 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace if regex on specific column matches expression?

I am attempting to convert rewrite rules to Nginx, and since due to the mass amount of rewrites we must convert, I've been trying to write a script to help me on a specific part, easily. So far I have this: rewrite ^action/static/(+)/$ staticPage.php?pg=$1&%$query_string; What I want done... (5 Replies)
Discussion started by: EXT3FSCK
5 Replies

2. Shell Programming and Scripting

Displaying lines of a file where the second field matches a pattern

Howdy. I know this is most likely possible using sed or awk or grep, most likely a combination of them together, but how would one go about running a grep like command on a file where you only try to match your pattern to the second field in a line, space delimited? Example: You are... (3 Replies)
Discussion started by: LordJezoX
3 Replies

3. Shell Programming and Scripting

Grep regex matches, groups

Hello, I am searching all over the place for this, just not finding anything solid :( I want to do be able to access the groups that are matched with grep (either with extended regex, or perl compatible regex). For instance: echo "abcd" | egrep "a(b(c(d)))" Of course this returns... (1 Reply)
Discussion started by: Rhije
1 Replies

4. Shell Programming and Scripting

Merge lines from one file if pattern matches

I have one comma separated file (a.txt) with two or more records all matching except for the last column. I would like to merge all matching lines into one and consolidate the last column, separated by ":". Does anyone know of a way to do this easily? I've searched the forum but most talked... (6 Replies)
Discussion started by: giannicello
6 Replies

5. Shell Programming and Scripting

script to delete lines from a txt file if pattern matches

File 6 dbnawldb010-b office Memphis_Corp_SQL_Diff Memphis-Corp-SQL-Inc-Application-Backup 03/09/11 03:24:04 42 luigi-b IPNRemitDB Memphis_Corp_SQL_Diff Memphis-Corp-SQL-Inc-Application-Backup 03/10/11 00:41:36 6 ebs-sqldev1-b IPNTracking Memphis_Corp_SQL_Diff... (4 Replies)
Discussion started by: ajiwww
4 Replies

6. Shell Programming and Scripting

SED Replacing all but one regex match on a line or specific matches

Hi, I'm attempting to rename some files that have spaces in them. Without linking sed commands together is it possible to replace the first three "." to " ". File.name.is.long.ext -> File name is long.ext I can get the desired effect with echo "File.name.is.long.ext" | sed 's/\./ /g;s/... (5 Replies)
Discussion started by: vectox
5 Replies

7. Shell Programming and Scripting

Help in printing n number of lines if a search string matches in a file

Hi I have below script which is used to grep specific errors and if error string matches send an email alert. Script is working fine , however , i wish to print next 10 lines of the string match to get the details of error in the email alert Current code:- #!/bin/bash tail -Fn0 --retry... (2 Replies)
Discussion started by: neha0785
2 Replies

8. Shell Programming and Scripting

Required 3 lines above the file and below file when string matches

i had requirement like i need to get "error" line of above 3 and below 3 from a file .I tried with the below script.But it's not working. y='grep -n -i error /home/file.txt|cut -c1' echo $y head -$y /home/file.txt| tail -3 >tmp.txt tail -$y /home/file.txt head -3 >>tmp.txt (4 Replies)
Discussion started by: bhas85
4 Replies

9. Shell Programming and Scripting

Exclude lines in a file with matches with multiple Strings using egrep

Hi I have a txt file and I would like to use egrep without using -v option to exclude the lines which matches with multiple Strings. Let's say I have some text in the txt file. The command should not fetch lines if they have strings something like CAT MAT DAT The command should fetch me... (4 Replies)
Discussion started by: Sathwik
4 Replies

10. Shell Programming and Scripting

awk to remove lines in file if specific field matches

I am trying to remove lines in the target.txt file if $5 before the - in that file matches sorted_list. I have tried grep and awk. Thank you :). grep grep -v -F -f targets.bed sort_list grep -vFf sort_list targets awk awk -F, ' > FILENAME == ARGV {to_remove=1; next} > ! ($5 in... (2 Replies)
Discussion started by: cmccabe
2 Replies
funcolumnactivate(3)						SAORD Documentation					      funcolumnactivate(3)

NAME
FunColumnActivate - activate Funtools columns SYNOPSIS
#include <funtools.h> void FunColumnActivate(Fun fun, char *s, char *plist) DESCRIPTION
The FunColumnActivate() routine determines which columns (set up by FunColumnSelect()) ultimately will be read and/or written. By default, all columns that are selected using FunColumnSelect() are activated. The FunColumnActivate() routine can be used to turn off/off activa- tion of specific columns. The first argument is the Fun handle associated with this set of columns. The second argument is a space-delimited list of columns to activate or de-activate. Columns preceded by "+" are activated and columns preceded by a "-" are de-activated. If a column is named with- out "+" or "-", it is activated. The reserved strings "$region" and '$n' are used to activate a special columns containing the filter region value and row value, respectively, associated with this row. For example, if a filter containing two circular regions is specified as part of the Funtools file name, this column will contain a value of 1 or 2, depending on which region that row was in. The reserved strings "$x" and "$y" are used to activate the current binning columns. Thus, if the columns DX and DY are specified as binning columns: [sh $] fundisp foo.fits[bincols=(DX,DY)] then "$x" and "$y" will refer to these columns in a call to FunColumnActivate(). In addition, if the activation string contains only columns to be activated, then the routine will de-activate all other columns. Simi- larly, if the activation string contains only columns to de-activate, then the routine will activate all other columns before activating the list. This makes it simple to change the activation state of all columns without having to know all of the column names. For example: o "pi pha time" # only these three columns will be active o "-pi -pha -time" # all but these columns will be active o "pi -pha" # only pi is active, pha is not, others are not o "+pi -pha" # same as above o "pi -pha -time" # only pi is active, all others are not o "pi pha" # pha and pi are active, all others are not o "pi pha -x -y" # pha and pi are active, all others are not You can use the column activation list to reorder columns, since columns are output in the order specified. For example: # default output order fundisp snr.ev'[cir 512 512 .1]' X Y PHA PI TIME DX DY -------- -------- -------- -------- --------------------- -------- -------- 512 512 6 7 79493997.45854475 578 574 512 512 8 9 79494575.58943175 579 573 512 512 5 6 79493631.03866175 578 575 512 512 5 5 79493290.86521725 578 575 512 512 8 9 79493432.00990875 579 573 # re-order the output by specifying explicit order fundisp snr.ev'[cir 512 512 .1]' "time x y dy dx pi pha" TIME X Y DY DX PI PHA --------------------- -------- -------- -------- -------- -------- -------- 79493997.45854475 512 512 574 578 7 6 79494575.58943175 512 512 573 579 9 8 79493631.03866175 512 512 575 578 6 5 79493290.86521725 512 512 575 578 5 5 79493432.00990875 512 512 573 579 9 8 A "+" sign by itself means to activate all columns, so that you can reorder just a few columns without specifying all of them: # reorder 3 columns and then output the rest fundisp snr.ev'[cir 512 512 .1]' "time pi pha +" TIME PI PHA Y X DX DY --------------------- -------- -------- -------- -------- -------- -------- 79493997.45854475 7 6 512 512 578 574 79494575.58943175 9 8 512 512 579 573 79493631.03866175 6 5 512 512 578 575 79493290.86521725 5 5 512 512 578 575 79493432.00990875 9 8 512 512 579 573 The column activation/deactivation is performed in the order of the specified column arguments. This means you can mix "+", "-" (which de- activates all columns) and specific column names to reorder and select columns in one command. For example, consider the following: # reorder and de-activate fundisp snr.ev'[cir 512 512 .1]' "time pi pha + -x -y" TIME PI PHA DX DY --------------------- -------- -------- -------- -------- 79493997.45854475 7 6 578 574 79494575.58943175 9 8 579 573 79493631.03866175 6 5 578 575 79493290.86521725 5 5 578 575 79493432.00990875 9 8 579 573 We first activate "time", "pi", and "pha" so that they are output first. We then activate all of the other columns, and then de-activate "x" and "y". Note that this is different from: # probably not what you want ... fundisp snr.ev'[cir 512 512 .1]' "time pi pha -x -y +" TIME PI PHA Y X DX DY --------------------- -------- -------- -------- -------- -------- -------- 79493997.45854475 7 6 512 512 578 574 79494575.58943175 9 8 512 512 579 573 79493631.03866175 6 5 512 512 578 575 79493290.86521725 5 5 512 512 578 575 79493432.00990875 9 8 512 512 579 573 Here, "x" and "y" are de-activated, but then all columns including "x" and "y" are again re-activated. Typically, FunColumnActivate() uses a list of columns that are passed into the program from the command line. For example, the code for funtable contains the following: char *cols=NULL; /* open the input FITS file */ if( !(fun = FunOpen(argv[1], "rc", NULL)) ) gerror(stderr, "could not FunOpen input file: %s ", argv[1]); /* set active flag for specified columns */ if( argc >= 4 ) cols = argv[3]; FunColumnActivate(fun, cols, NULL); The FunOpen() call sets the default columns to be all columns in the input file. The FunColumnActivate() call then allows the user to con- trol which columns ultimately will be activated (i.e., in this case, written to the new file). For example: funtable test.ev foo.ev "pi pha time" will process only the three columns mentioned, while: funtable test.ev foo.ev "-time" will process all columns except "time". If FunColumnActivate() is called with a null string, then the environment variable FUN_COLUMNS will be used to provide a global value, if present. This is the reason why we call the routine even if no columns are specified on the command line (see example above), instead of calling it this way: /* set active flag for specified columns */ if( argc >= 4 ){ FunColumnActivate(fun, argv[3], NULL); } SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funcolumnactivate(3)
All times are GMT -4. The time now is 05:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy