Visit Our UNIX and Linux User Community

Search distinct files

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search distinct files
# 1  
Old 07-26-2011
Search distinct files

Hello ,

Can anyone help me with my below query

I am trying to find a text in directory of files via below command

grep -i cmps_cgs_crs_rfnc_id *

But it returns multiple times same file name i.e if the text found in a file 4 times the file name shown 4 times in the o/p

Is there anyway to get the filename once doesn't matter how many times it appears in the file

Thanks a lot!!!!!!!!!!!!!!!
# 2  
Old 07-26-2011
grep -il cmps_cgs_crs_rfnc_id *

if you have gnu grep then you can try the below

grep -m 1 -i cmps_cgs_crs_rfnc_id *

This User Gave Thanks to itkamaraj For This Post:

Previous Thread | Next Thread
Test Your Knowledge in Computers #104
Difficulty: Easy
Unix is a family of multitasking, portable, multi-user computer operating systems, which do not have time-sharing capability.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding total distinct count from multiple csv files through UNIX script

Hi All , I have multiple pipe delimited csv files are present in a directory.I need to find out distinct count on a column on those files and need the total distinct count on all files. We can't merge all the files here as file size are huge in millions.I have tried in below way for each... (9 Replies)
Discussion started by: STCET22
9 Replies

2. Shell Programming and Scripting

Find distinct files in directory

Hi All, I am working on one of the script developement for my project, where I need to find the distinct types of files from given directory based on pattern provided. for e.g. directory listing is : abc123.dat.20141212_021012 abc123.dat.20141312_041012 abc123.dat.20141112_031012... (5 Replies)
Discussion started by: freakabhi
5 Replies

3. Shell Programming and Scripting

To search distinct special char in file

hi, i need to search distinct special character from a file which is a pipe delimited from a specific column for eg: input file.txt aa|bb|cc|$abc aa|bb|ccc|#abol bb|xss|ddd|$xyz nn|yyy|qqq|=qqqq abe|qqq|yyy|=aaa aaa|yyy|zzzz|#aaaa . . . my desired output $ (10 Replies)
Discussion started by: rohit_shinez
10 Replies

4. Shell Programming and Scripting

search information in multiple files and save in new files

hi everyone, im stuck in here with shell :) can you help me?? i have a directory with alot files (genbank files ... all ended in .gbk ) more than 1000 for sure ... and i want to read each one of them and search for some information and if i found the right one i save in new file with new... (6 Replies)
Discussion started by: andreia
6 Replies

5. Shell Programming and Scripting

search for content in files. Name of files is in another file. Format as report.

Hi I have multiple files in a folder and one file which contains a list of files (one on each line). I was to search for a string only within these files and not the whole folder. I need the output to be in the form File1<tab>string instance 2<tab> string instance 2<tab>string instance 3... (6 Replies)
Discussion started by: pkabali
6 Replies

6. Shell Programming and Scripting

How to access files from different directories and to perform search action in those files?

Hi, I want to access files from different directories (for example: /home/dir1/file1 , /home/dir2/file2 ...) Like this i have to access these files(file1, file2...). (3 Replies)
Discussion started by: bangarukannan
3 Replies

7. SuSE

Search all files based on first and in all listed files search the second patterns

Hello Linux Masters, I am not a linux expert therefore i need help from linux gurus. Well i have a requirement where i need to search all files based on first patterns and after seraching all files then serach second pattern in all files which i have extracted based on first pattern.... (1 Reply)
Discussion started by: Black-Linux
1 Replies

8. Solaris

Look for distinct files under a directory matching a pattern

Hi, I'm searching for a pattern 'java' under a directory but it is returning all the files containing 'java', but I want to have only distinct files not all. please help (2 Replies)
Discussion started by: b.paramanatti
2 Replies

9. UNIX for Dummies Questions & Answers

Distinct search usisng GREP cmd

Hi All, I have the following problem where I have been trying but not able to resolve it:- I have a file which has some thousands entries. For eg:- The content of the file is :- ============================================== ./admin.cpp:9:#include "framework/RegistryContext.h"... (2 Replies)
Discussion started by: shubhranshu
2 Replies

10. UNIX for Advanced & Expert Users

Search files with specfic extention and later search content

Hi, I would appriciate if somebody can help me figure out how to search for all the *.xml file under a specific directory and subdirectroies (/home/username) and later search of content "<start>" inside the xml file returned by search. -Lovin.V (2 Replies)
Discussion started by: lovi_v
2 Replies

Featured Tech Videos