04-27-2004
Perderabo,
The example you gave removes all spaces from the input line, while I need to remove only redundant spaces. But you did give me a good push in the right direction. Here's what I came up with:
ls "$path" | xargs nawk '{print "("FILENAME") "$0}' | tr -s " " | fgrep -i "$search_arg"
Thank you, and everyone who contributed!
Last edited by netguy; 04-27-2004 at 01:19 AM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I have over 200 files and some of them have the string like "John price $200". I would like to grep the string. Then output the filename which found the string.
I have the following script, but it ONLY output the string
echo Please input list file name:
read listn
for file in `cat... (3 Replies)
Discussion started by: happyv
3 Replies
2. Shell Programming and Scripting
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
3. UNIX for Dummies Questions & Answers
Hi all,
I am trying to zgrep / grep list of files so that it displays only the matching filename:line number and does not display the whole line, like:
(echo "1.txt";echo "2.txt") | xargs zgrep -no STRING
If I use -o option, it displays the matching STRING and if not used, displays the... (3 Replies)
Discussion started by: vvaidyan
3 Replies
4. Shell Programming and Scripting
Hi all
i'm new in KSH,
i want to write a script to grep a logs files and redirecting the result into a relative subdirectory/file.txt that must be created near to each log file
my begin script is :
find ./logs -type f -name "*.log" -exec grep error {} \;
how i can perform that modest... (10 Replies)
Discussion started by: rambler
10 Replies
5. Shell Programming and Scripting
Explain this?
$ ls | grep -e "crd\|cs"
crd
cs
$ CLONES=`ls | grep -e "crd\|cs"`;echo $CLONES;
crd cs
$ CLONES=`ls | grep -e "crd\|cs"`;echo "$CLONES";
crd
cs (1 Reply)
Discussion started by: blasto333
1 Replies
6. Shell Programming and Scripting
Hi All,
Can you please help me.
The situation is like this. There are many different file name in this directory.
I have to grep all the file that the name start with "PTWO" and rename it to COM with the current date.
This is the script that I have done and it hit an... (16 Replies)
Discussion started by: badbunny9316
16 Replies
7. Shell Programming and Scripting
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
Hi,
Can anyone let me know what is difference between
grep .* foo.c
grep '.*' foo.c
I am not able to understand what is exact difference.
Thanks in advance (2 Replies)
Discussion started by: SasDutta
2 Replies
9. UNIX for Dummies Questions & Answers
There is a file name list_filenames.dat, this has all the list of all files I need to encrypt, I did not understand what the following syntax is doing:
grep -s "^$1" list_filenames.dat, when I manually run this command it just returns all the lines, what is the usage of this ? can someone... (4 Replies)
Discussion started by: okkadu
4 Replies
10. Shell Programming and Scripting
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
LEARN ABOUT LINUX
bzegrep
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)