Diff between grep .* file name and grep '.*' filename


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Diff between grep .* file name and grep '.*' filename
# 1  
Old 11-19-2012
Diff between grep .* file name and grep '.*' filename

Hi,

Can anyone let me know what is difference between
Code:
grep .* foo.c 

grep '.*' foo.c

I am not able to understand what is exact difference.

Thanks in advance

Last edited by jim mcnamara; 11-19-2012 at 07:11 PM..
# 2  
Old 11-19-2012
Looks like a homework question
# 3  
Old 11-19-2012
The '*' is not expanded by the shell into filenames. *,? and other characters in the shell are metacharacters, they represent something "beyond" themselves as basic characters - in this case * is a wild card for filenames.

If this is homework post any followups in the homework forum. It has different rules.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to grep for a string on a FILENAME?

I call my bash shell script "test.sh" and pass "admin_usr.txt" as an argument like below. ./test.sh admin_usr.txt Inside the "test.sh" i wish to check if the filename passed "admin_usr.txt" i.e "$1" contains the string "admin" or not ... which in this case it does. Note: I do not wish to... (5 Replies)
Discussion started by: mohtashims
5 Replies

2. Shell Programming and Scripting

Grep -v -f and sort|diff which way is faster

Hi Gurus, I have two big files. I need to compare the different. currently, I am using sort file1 > file1_temp; sort file2 > file2_tmp diff file1_tmp file2_tmp I can use command grep -v -f file1 file2 just wondering which way is fast to compare two big files. Thanks... (4 Replies)
Discussion started by: ken6503
4 Replies

3. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

4. Shell Programming and Scripting

[awk] grep a part of filename as entry file

hi all, i need to combine these files into one csv file. Bounce_Mail_Event_Daily_Report_01_Jul_2012.csv Bounce_Mail_Event_Daily_Report_02_Jul_2012.csv Bounce_Mail_Event_Daily_Report_03_Jul_2012.csv Bounce_Mail_Event_Daily_Report_04_Jul_2012.csv... (10 Replies)
Discussion started by: makan
10 Replies

5. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

6. Shell Programming and Scripting

serach diff filename in diff location using shell scripting

Hi, I am new to shell scripting. please help me to find out the solution. I need a script where we need to read the text file(consists of all file names) and get the file names one by one and append the date suffix for each file name as 'yyyymmdd' . Then search each file if exists... (1 Reply)
Discussion started by: Lucky123
1 Replies

7. Shell Programming and Scripting

grep for pattern in filename

Hey guys, here is my code: #!/bin/bash filter=('ubb' 'um2' 'uuu' 'uvv' 'uw1' 'uw2' 'uwh') let num=`ls -l | grep 'sk' | wc -l` read -a lines <<< `ls -l | grep 'sk' | awk '{print $8}'` let finum=${#fi} for ((i=1;i<=$num;i++)) do for ((c=4;c<6;c++)) ... (2 Replies)
Discussion started by: jkobori
2 Replies

8. Shell Programming and Scripting

[solved] Diff between two files by grep

My requiremeny is as follows, I have two files file a A BONES RD,NHILL,3418,VIC 37TH PARALLEL RD,DEEP LEAD,3385,VIC 4 AK RD,OAKEY,4401,QLD A & J FARRS RD,BARMOYA,4703,QLD A B PATTERSON DR,ARUNDEL,4214,QLD A BLAIRS RD,BUCKRABANYULE,3525,VIC file b A BONES... (12 Replies)
Discussion started by: feelmyfrd
12 Replies

9. Shell Programming and Scripting

grep for certain files using a file as input to grep and then move

Hi All, I need to grep few files which has words like the below in the file name , which i want to put it in a file and and grep for the files which contain these names and move it to a new directory , full file name -C20091210.1000-20091210.1100_SMGBSC3:1000... (2 Replies)
Discussion started by: anita07
2 Replies

10. Shell Programming and Scripting

using grep and print filename

Hi, I have a question on bash. Basically I would like to print a file name using bash. I am actually trying to grep a particular character in sequential files. I have alot files such that a.txt, b.txt,c.txt...etc. If I found a certain character, I would print that particular filename. I... (5 Replies)
Discussion started by: ahjiefreak
5 Replies
Login or Register to Ask a Question