Sponsored Content
Top Forums Shell Programming and Scripting Grep command is not search the complete pattern Post 302825763 by sumit.vedi1988 on Tuesday 25th of June 2013 06:05:48 AM
Old 06-25-2013
Grep command is not search the complete pattern

I am facing a problem while using the grep command in shell script. Actually I have one file (PCF_STARHUB_20130625_1) which contain below records.
Code:
SH_5.55916.00.00.100029_20130601_0001_NUC.csv.gz|438|3556691115 
SH_5.55916.00.00.100029_20130601_0001_Summary.csv.gz|275|3919504621 
SH_5.55916.00.00.100029_20130601_0001_UI.csv.gz|226|593316831
SH_5.55916.00.00.100029_20130601_0001_US.csv.gz|349|1700116234 
SH_5.55916.00.00.100038_20130601_0001_NUC.csv.gz|368|3553014997
SH_5.55916.00.00.100038_20130601_0001_Summary.csv.gz|276|2625719449 
SH_5.55916.00.00.100038_20130601_0001_UI.csv.gz|226|3825232121 
SH_5.55916.00.00.100038_20130601_0001_US.csv.gz|199|2099616349 
SH_5.75470.00.00.100015_20130601_0001_NUC.csv.gz|425|1627227450

And I have a pattern which is stored in one variable (INPUT_FILE_T), and want to search the pattern from the file (PCF_STARHUB_20130625_1). For that I have used below command
Code:
INPUT_FILE_T="SH?*???????????????US.*" 
grep -h ${INPUT_FILE_T} PCF_STARHUB_20130625_1

The output of above command is coming as below
Code:
SH_5.55916.00.00.100029_20130601_0001_US.csv.gz|349|1700116234

Problem is that only one entry is showing in output (It should contain two entries) output should come like below
Code:
SH_5.55916.00.00.100029_20130601_0001_US.csv.gz|349|1700116234
SH_5.55916.00.00.100038_20130601_0001_US.csv.gz|199|2099616349

Is there any technique except grep please tell me.
Please help me on this issue.

Last edited by sumit.vedi1988; 06-25-2013 at 07:11 AM.. Reason: formating
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

search pattern by grep

hai folks, i am vijay very new to this website. My query: Search patterns from root directory to all directories by using grep (3 Replies)
Discussion started by: vijaysabari
3 Replies

2. UNIX for Dummies Questions & Answers

grep line pattern search

Hello everyone, I have been trying to get a list of all files containing a line of this type: };#followed by anything with any spaces (0 or more or 0 or more tabs) before the } and between each of the characters. I have been trying this : grep '*}*;*#*' *.c but I have not been fully... (1 Reply)
Discussion started by: gio001
1 Replies

3. UNIX for Dummies Questions & Answers

Can grep command return word instead of complete line

Hi Is there any way GREP command can return word and not complete line. My file has following data: Hello Everyone I am NitinrajSrivastava Hi Friends Welcome VrajSrivastava I am using grep 'raj' which is returning me complete line.However I want only the word having keyword 'raj'. Required... (11 Replies)
Discussion started by: dashing201
11 Replies

4. Shell Programming and Scripting

search for a pattern using grep

Hi I am facing the below problem. I have set of lines in which i have to search for only the line which matches with the pattren "/" only. input:- /*+ some text */ /*+ some text */ /* Remove rows from a table of survey results. */ /* Add a survey respondent's name and answers. */ /*... (7 Replies)
Discussion started by: manasa_vs
7 Replies

5. Shell Programming and Scripting

Pattern search using grep command !

Hi, I am trying to do pattern search using grep command. But i donot know what mistake i'm doing. I am not getting the expected Result. could any one please help me out? $ cat b.ksh AasdjfhB 57834B 86234B 472346B I want to print the line which is starting with either A or 8 and... (10 Replies)
Discussion started by: nikesh29
10 Replies

6. Shell Programming and Scripting

How can i use grep to search a specific pattern?

Hi All, My file contain the below data : w_SA_infa1.log:INFO : LM_36620 : () Command task instance : running command , with command value . Binary file w_SA_infa1.log.bin matches w_SA_infa2.log:INFO : LM_36620 : (30377|1427806528) Command task instance : running command , with command value... (1 Reply)
Discussion started by: aliva Dash
1 Replies

7. UNIX for Advanced & Expert Users

Pattern Search with grep

Hello, I have a bunch of zip files like SS_SAMPLE_101_123.zip SS_101_123.zip SS_SAMPLE_121_345.zip SS_SAMPLE_222_678.zip SS_123_890.zip SS_.zip The 'ls' should search and list the files such as SS_101_123.zip and SS_123_890.zip alone. Could you please guide me with this.... (5 Replies)
Discussion started by: tinufarid
5 Replies

8. Shell Programming and Scripting

Search file pattern using grep command

I 'm writing a script to search particular strings from log files. The log file contains lines start with *. The file may contain many other lines start with *. I need to search a particular line from my log file. The grep command is working in command line , but when i run my script, Its printing... (7 Replies)
Discussion started by: vinus
7 Replies

9. Shell Programming and Scripting

Grep command to search pattern corresponding to input from user

One more question: I want to grep "COS_12_TM_4 pattern from a file look likes : "COS_12_TM_4" " ];I am taking scan_out as the input from the user. How to search "COS_12_TM_4" in the file which is corresponds to scan_out (12 Replies)
Discussion started by: Preeti Chandra
12 Replies

10. UNIX for Beginners Questions & Answers

Grep/awk using a begin search pattern and end search pattern

I have this fileA TEST FILE ABC this file contains ABC; TEST FILE DGHT this file contains DGHT; TEST FILE 123 this file contains ABC, this file contains DEF, this file contains XYZ, this file contains KLM ; I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Discussion started by: vbabz
2 Replies
GREP(1) 						      General Commands Manual							   GREP(1)

NAME
grep - search a file for lines containing a given pattern SYNOPSIS
grep [-elnsv] pattern [file] ... OPTIONS
-e -e pattern is the same as pattern -c Print a count of lines matched -i Ignore case -l Print file names, no lines -n Print line numbers -s Status only, no printed output -v Select lines that do not match EXAMPLES
grep mouse file # Find lines in file containing mouse grep [0-9] file # Print lines containing a digit DESCRIPTION
Grep searches one or more files (by default, stdin) and selects out all the lines that match the pattern. All the regular expressions accepted by ed and mined are allowed. In addition, + can be used instead of * to mean 1 or more occurrences, ? can be used to mean 0 or 1 occurrences, and | can be used between two regular expressions to mean either one of them. Parentheses can be used for grouping. If a match is found, exit status 0 is returned. If no match is found, exit status 1 is returned. If an error is detected, exit status 2 is returned. SEE ALSO
cgrep(1), fgrep(1), sed(1), awk(9). GREP(1)
All times are GMT -4. The time now is 03:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy