Grep showing all files name of the directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep showing all files name of the directory
# 1  
Old 12-06-2013
Grep showing all files name of the directory

Hi All,

Can any one help me here.I'm getting whole files name of the directory along with the grep result.

below is the code
Code:
 
var=`grep -i '127.3.3.1' _record`
echo $var

# 2  
Old 12-06-2013
What is "whole files name"?
Is your grep aliased?
# 3  
Old 12-06-2013
Thanks for reply Rudic !!

Whole files name here means all the other files name which is present in the current directory.

For you refrence o/p of the above code.

Code:
 
"26731","47710","TEST","ADMIN","127.3.3.1","select 1 1.cron_dup 1.out 1.sql 912650.pln abc.out aginity A.out B.out check234 C.out create_mytable create_mytable.out dynamictables1 empty et1_region_flat_file exclusionfield1 exclusionfield1.out exclusionfilterchar file1 final_report.out fstm greatest.cpp greatest.o_spu10 greatest.o_x86 health.sh health_test.sh hostbackup if_test load1.dat long long_aginity longrunning.csv longrunning_edit.csv longrunning_edit.csv_old msg1.out msgatach.out msgattach.out msgBody.txt msg.out MSTR mytest_2370271.pln my_test_table_in_place2370368.pln Netezza permission query_5674337_final query_test rav_a.out _record region row.out runaway runaway_1 runaway_3 runaway_3_msg.out runaway_new.sh runaway.out runaway_priya.sh runaway_test sample.out session size_info_old.out size_info.out size.out sql_not_in_place_of_view.out sql_not_in_place_of_view.out1 sql_table_in_place_of_view.out sql.txt sql.txt2 sqltxt26 sqltxt26.out sql.txt2_format sql.txt2.out stats sts.log sytm.out sytm.txt TABLE1.1 temp1 temp1.csv temp1.out temp2.out temp3.out test000 test007 test101 test101.csv test102 test103 test104 test105 test1.sh test222 test2222 test222_msg.out test22.sh test23.sh test333 test333.out test444 test_aatch test_case test_create test_create.create_out test_create.create.out test_diag test_grep_ip testkkk testkkk.out test_session

# 4  
Old 12-06-2013
Well, I guess that's the line in _record that has 127.3.3.1 in it.
# 5  
Old 12-06-2013
No Rudic.

These are the files name in current directory.Only till select is the content in the file '_record'
# 6  
Old 12-06-2013
Is _record a flat file, or a directory?

Is that your entire script, or is there some other stuff around it?
# 7  
Old 12-06-2013
_record is a flat file

This is the only thing in the script.

Code:
 
var=`grep -i '127.3.3.1' _record`
echo $var

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep for all ip addresses mentioned in all files in a Directory

I wish to traverse all files and folders under a given directory say "/tmp/configuration" and for all ip address mentioned therein. I tried find ./ -type f | xargs grep "*.*.*.*" but it does not populated the correct results. Can you please suggest. (1 Reply)
Discussion started by: mohtashims
1 Replies

2. Shell Programming and Scripting

How to grep all the files inside the directory and Sub directory

Hi, I have used the command cat * | grep -r <<String>> * It returns: cat : JAN : is directory *********************** ********************* My directory structure: log - JAN -catalina.out -FEB -catalina.out -MARCH ... (11 Replies)
Discussion started by: nanthagopal
11 Replies

3. Shell Programming and Scripting

Grep command showing wrong output in Linux

Hi All I am trying to run a script in linux wherein i have a command like this grep ^prmAttunityUser= djpHewr2XFMAttunitySetup_ae1_tmp djpHewr2XFMAttunitySetup_ae1_tmp is a temporary file in which the user value is stored but this command in the script returns me balnk value whereas it has a... (4 Replies)
Discussion started by: vee_789
4 Replies

4. HP-UX

[Solved] /var directory in HP-UX is showing 95%?

Hi Everyone, My var directory is showing near to 100% ? What are the files should i delete to make it less?? Kindly suggest # bdf -i Filesystem kbytes used avail %used iused ifree %iuse Mounted on /dev/vg00/lvol3 1048576 107616 933616 10% 3342 29394 10% /... (10 Replies)
Discussion started by: yadvinder
10 Replies

5. Shell Programming and Scripting

Finding the executable files of a directory using Grep

Hi guys, Can you please help me print all the executable files of a directory(in this case /home) using grep? All i know is that this command should do it but it doesnt... ls -l ~ | grep -..x it shows me the following mesage grep: invalid option -- '.' Χρήση: grep ... ΥΠΟΔΕΙΓΜΑ ... (3 Replies)
Discussion started by: jimas13
3 Replies

6. UNIX for Dummies Questions & Answers

Help with grep - not showing filenames

Hello, I'm looking for a search string within about 50 files but when the string is found it doesn't tell me in which member it has been found. Any ideas how I can do this? Cheers Rob (4 Replies)
Discussion started by: Grueben
4 Replies

7. Shell Programming and Scripting

CWD in prompt only showing the directory when set

Hi Gurus, I am working in tcsh and i set the prompt with this. set prompt = "$cwd>" But I see teh prompt only gets reflected with the directory where I set the prompt. After i cd to another directory it still shows the old directory. Please advise (1 Reply)
Discussion started by: kinny
1 Replies

8. Shell Programming and Scripting

grep all files in a directory

I am not sure if i am doing this correctly since it returns quickly. i need to grep for a keyword in all files in a directory grep keyword /mydirectory is that correct? I just want to know which files have a keyword in it. i am using korn shell in solaris 5.1. There does not appear to... (12 Replies)
Discussion started by: guessingo
12 Replies

9. Shell Programming and Scripting

grep and awk showing filename in loop

I am attempting to grep a list of files for a string an and then only extract the 3rd and 4th field of from the line. That's easy. But I want to prefix the line with the filename that the information came from. for filename in `ls -1 *.txt' do grep search_text $filename | awk '{print $3"... (5 Replies)
Discussion started by: sjohns6
5 Replies

10. AIX

Help Using Grep command to Find the string in the files in the root directory

I want to serch for a string in all the files in the root directory. i want the search to be limited to only the files in the directory i.e the search to be done only in the files not in the sub directory. the approaches tried are 1)grep "pattern string" this command was serching the... (3 Replies)
Discussion started by: Subbu_Angeline
3 Replies
Login or Register to Ask a Question