Sponsored Content
Top Forums Shell Programming and Scripting How to handle grepping variable data containing wildcards? Post 302983357 by shamrock on Monday 10th of October 2016 02:49:29 PM
Old 10-10-2016
No need for the while loop...first remove everything that follows the comma on each line of the pattern file with awk and pipe its output to grep...
Code:
awk -F, '{print $1}' pattern_file | xargs grep {} $source_file

This User Gave Thanks to shamrock For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grepping using multiple wildcards

Is there anyway you can grep using multiple wildcards? When I run the below line the results return fine; grep 12345 /usr/local/production/soccermatchplus/distributor/clients/*/out/fixtures.xml | awk -F/ '{print $8}' However ideally, I need it to grep for; grep 12345... (3 Replies)
Discussion started by: JayC89
3 Replies

2. UNIX for Dummies Questions & Answers

grepping a variable

I need to pass a parameter that will then be grepped. I need it to grep /paramater and then have a space so if 123 was passed my grep would be grep '/123 ' sample.log this works fine from the command line but when i try and set it searchThis="/$2 " and then run grep $searchThis... (6 Replies)
Discussion started by: magnia
6 Replies

3. Shell Programming and Scripting

Grepping Date Variable

Hello, I would like for the user to input the date for a particular log file, then have the input sent to a variable, which is then used via grep to extra the logs for the specific date the user request. I did some searching, but I still don't understand why I'm not seeing any result. ... (4 Replies)
Discussion started by: ravzter
4 Replies

4. Shell Programming and Scripting

problem in using cgi_script to handle form data

Hi, I have an HTML form through which I get some text as input. i need to run a shell script say script.sh inside a perl-cgi script named main_cgi.sh on the form input. I want to write the contents of the form in a file and then perform some command line operations like grep, cat on the text... (0 Replies)
Discussion started by: piyush_priya
0 Replies

5. Shell Programming and Scripting

Help with grepping data from a text file

Hello, I have a text file which contains a list of strings which I want to grep from another file where these strings occur and print out only these lines. I had earlier used the grep command where File1 was the file containing the strings to be grepped (Source File) and File2 the Target File... (4 Replies)
Discussion started by: gimley
4 Replies

6. Shell Programming and Scripting

Grepping for variable in brackets

I have a script which reads a number out of a log file. The pertinent line is this: cat /tmp/listofnumbers When I run cat /tmp/listofnumbers what I am seeing is on each line. I am trying to make the script read from that file and grep for a variable like the following line should do: ... (4 Replies)
Discussion started by: newbie2010
4 Replies

7. Shell Programming and Scripting

Grepping data using awk

Hello, I have a data in file 1 2000000024776 2000000026979 2000000033355 2000000036309 2000000041291 2000000042679 2000000067221 and in file 2 its like this 2000000024776 16 2000000026979 16 2000000033355 16 (2 Replies)
Discussion started by: mirwasim
2 Replies

8. Shell Programming and Scripting

Grepping the data between 2 date ranges

Hi There, Good Day !! I have txt file containing data in the below format. There are many lines, here i have mentioned for example. cat remo.txt 2/3/2017 file1 3/4/2016 file2 6/6/2015 file5 1/1/2018 file3 4/3/2014 file4 - - - I need to grep the file names for given date rage... (11 Replies)
Discussion started by: kumar85shiv
11 Replies

9. UNIX for Beginners Questions & Answers

Expand Variables and Wildcards into another variable.

Dear Forum members, I am having trouble getting the complete filename (and directory path) in a variable. Output directory mentioned in the code have three files: DISPLAY_CITY_DETAILS_15-05-2019-08-29-26_MIGRATE_london.out DISPLAY_CITY_DETAILS_15-05-2019-08-29-26_MIGRATE_paris.out... (4 Replies)
Discussion started by: chetanojha
4 Replies

10. UNIX for Beginners Questions & Answers

Grepping for one variable while using awk to parse an associated variable

Im trying to search for a single variable in the first field and from that output use awk to extract out the lines that contain a value less than a value stored in another variable. Both the variables are associated with each other. Any guidance is appreciated. File that contains the... (6 Replies)
Discussion started by: ncwxpanther
6 Replies
fitsort(1)						      General Commands Manual							fitsort(1)

NAME
fitsort - sort FITS header information from a list of files SYNOPSIS
dfits <FITS files...> | fitsort <FITS keywords...> DESCRIPTION
fitsort extract keyword values from a set of FITS headers and outputs it in an ASCII table format, which is compatible with most data pro- cessing software packages. It shall only be used in combination with the dfits utility. The ASCII output is shown in columns. Columns are aligned with blank characters and also separated by tabulations. Blank alignment allows human readers to visualize the output in a pretty format, tabulations are there for spreadsheet compatibility. If you want to load out fit- sort output into any spreadsheet, specify that fields shall be separated by tabulations and entries separated by linefeeds. Examples : dfits *.fits | fitsort BITPIX NAXIS NAXIS1 NAXIS2 The output would look like: FILE BITPIX NAXIS NAXIS1 NAXIS2 file0001.fits 16 2 128 128 file0002.fits 32 2 512 512 ... ESO specific features in the FITS header are also supported. To get values for 'HIERARCH ESO' keywords, just give the complete names within double quotes. e.g. dfits *.fits | fitsort "HIERARCH ESO INS LENS" Another way of giving HIERARCH ESO keywords is to use the short FITS notation, the above example can be given as: dfits *.fits | fitsort INS.LENS Example: to retrieve the DPR keywords from an ESO FITS header, you would use: dfits *.fits | fitsort To be completed... DPR.CATG DPR.TYPE DPR.TECH This second way of requesting HIERARCH ESO keywords is not only shorter to type, it also avoids typing quotes or double-quotes on the com- mand-line, making it easier to script with fitsort. Notice that the keywords you give on the command-line are case-insensitive. The above line is equivalent to: dfits *.fits | fitsort dpr.catg dpr.type dpr.tech OPTIONS
-d Do not print out the first output line. This option is useful to get only the query results, without the top line (giving all column names). This makes it easy to script fitsort from programs like awk or perl. FILES
Input files to dfits shall all comply with FITS format. fitsort also supports HIERARCH ESO FITS format. SEE ALSO
dfits (1) 25 Jun 2001 fitsort(1)
All times are GMT -4. The time now is 07:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy