06-02-2001
One of the features of grep is that if you specify more than one file to search it will show any matches prefixed by the filename. So I specify /dev/null as a second file to search. It will never match, and will always exist. You could really use any file, but /dev/null is a safe choice.
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am using command substitution into a find command in a script where I have built a menu to do a bunch of tasks within my unix account. When I choose the options for to find a file/files that have the same inode of the entered filename, ie hardlinks, nothing shows up. When I choose the appropiate... (2 Replies)
Discussion started by: hunternjb
2 Replies
2. Shell Programming and Scripting
Dear Experts,
Please help to teach me how to add the filename into the file content.
Actually the file name are EVENTS-20050912.
***************New output that I want***************
EVENTS-20050912 03:33:37 ALARM: BTSSPAN-277-1 30-18013
EVENTS-20050912 12:10:28 ALARM: BTSSPAN-297-2... (1 Reply)
Discussion started by: missutoomuch
1 Replies
3. UNIX for Advanced & Expert Users
Hi,
I am currently using the following command:
files=(ls enuCPU??.????.exp ntuCPU??.????.exp)
I need to now change the commmand to store the file names of files that have been modified before datetime equal to say '02/16/2008 20:30:00'
What could I use? (2 Replies)
Discussion started by: edisonantus
2 Replies
4. Shell Programming and Scripting
Hi,
I have to rename all occurance of CUST_MST to RESELLER_MST both in filename and file content under a directory (say D0) which contains multiple (2-3 levels) sub directory.
Example:
D0 -> D1 -> D2 has a file CUST_MST_TEMP.txt
this contains :
> cat /D0/D1/D2/CUST_MST_TEMP.txt... (3 Replies)
Discussion started by: sabyasm
3 Replies
5. Shell Programming and Scripting
How can I search for a string in a filename? For example, I want to know if a filename (not the file contents) contains the string "test". (3 Replies)
Discussion started by: daflore
3 Replies
6. Shell Programming and Scripting
Hi,
We've a list of files that gets created on a weekly basis and it has got a date and time embedded to it. Below are the examples. I want to find out how to get the latest files get the date and time stamp out of it.
Files are
PQR123.PLL.M989898.201308012254.gpg... (1 Reply)
Discussion started by: rudoraj
1 Replies
7. UNIX for Dummies Questions & Answers
Hi all,
I am a newbie here. I have this requirement to find a file based on a pattern then return the filename if found.
I created a script based on online tutorials. Though, I am stuck & really appreciate if anyone can have a quick look & point me to the right direction?
#Script starts... (10 Replies)
Discussion started by: buster_t
10 Replies
8. UNIX for Dummies Questions & Answers
This should recursively walk through all dirictories and
search for a specified string in all present files, if found
output manicured content (eg some regex) with CAT into
a specified directory (eg /tmp/)
one by one, keeping the original names
This is what I have so far, which seems to... (1 Reply)
Discussion started by: lowmaster
1 Replies
9. Shell Programming and Scripting
Hello,
Is possibly there a way to prepend the filename to its content without a third file? The reason is to add a header to each file contents to distinguish each other when they are pasted side-by-side.
sample.txt:
XLOC_001 0
XLOC_002 23
XLOC_003 4
XLOC_012 6output (with the same... (4 Replies)
Discussion started by: yifangt
4 Replies
LEARN ABOUT LINUX
bzfgrep
BZGREP(1) General Commands Manual BZGREP(1)
NAME
bzgrep, bzfgrep, bzegrep - search possibly bzip2 compressed files for a regular expression
SYNOPSIS
bzgrep [ grep_options ] [ -e ] pattern filename...
bzegrep [ egrep_options ] [ -e ] pattern filename...
bzfgrep [ fgrep_options ] [ -e ] pattern filename...
DESCRIPTION
Bzgrep is used to invoke the grep on bzip2-compressed files. All options specified are passed directly to grep. If no file is specified,
then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to
grep.
If bzgrep is invoked as bzegrep or bzfgrep then egrep or fgrep is used instead of grep. If the GREP environment variable is set, bzgrep
uses it as the grep program to be invoked. For example:
for sh: GREP=fgrep bzgrep string files
for csh: (setenv GREP fgrep; bzgrep string files)
AUTHOR
Charles Levert (charles@comm.polymtl.ca). Adapted to bzip2 by Philippe Troin <phil@fifi.org> for Debian GNU/Linux.
SEE ALSO
grep(1), egrep(1), fgrep(1), bzdiff(1), bzmore(1), bzless(1), bzip2(1)
BZGREP(1)