02-27-2009
Can you explain what you mean by 'delimited?'
I just copied the NeoOffice file (saved as .doc, a word format) to text edit (a .txt file) and the command worked (grep 'I am writing') but it printed the whole letter, or most of it -- which I'm guessing means that it found all the lines with any of the three words in the string and printed those lines. Is it possible to use 'grep' to find this particular sentence fragment and no other lines which don't contain this entire fragment?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I need to extract information from a 4 GB file based on the following conditions:
1) Check for the presence of a set of account numbers
Each account number is present along with other information within
a PAGESTART and PAGEEND.
The file looks like this:
PAGESTART
ACCOUNT NO 123... (6 Replies)
Discussion started by: kthri
6 Replies
2. Shell Programming and Scripting
I wanna grep for a pattern logs 1 2 & 3 within a folder containing 100 logs
grep "test" /folder/log1 /folder/log2 /folder/log3
The above command will work fine
but is there any command like
grep "test" /folder/log1, log2, log3 or something similar (4 Replies)
Discussion started by: roshanjain2
4 Replies
3. Shell Programming and Scripting
Net::SSH::Perl ...... how to print the output in a proper format
my $cmd = "ls -l";
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pass);
my($stdout, $stderr, $exit) = $ssh->cmd("$cmd");
print $stdout;
the script works fine, but i am unable to see the output... (2 Replies)
Discussion started by: gsprasanna
2 Replies
4. UNIX for Dummies Questions & Answers
Hello,
I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide.
ls -aLl /bin | grep "\(x\)"
Which works, just highlights 'x' where ever, when ever.
I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies
5. UNIX for Dummies Questions & Answers
I'm new to Unix, and just had a quick question.
I'm writing a bash script, and I was wondering what proper programming etiquette was for piping. How many pipes is too many pipes?
OLDEST=$(find . -maxdepth 1 -type d -newermt 2012-07-01 ! -newermt
2012-07-30 | xargs ls -1td | tail -2)
echo... (1 Reply)
Discussion started by: jrymer
1 Replies
6. Shell Programming and Scripting
Hi Guys,
I need to grep below data in this format
backup_id
creation
expiration
policy
sched_label
backup_id = picoserver38_1212077050, version = 2
creation = 05/29/2008 18:04:10 (1212077050)
expiration = 06/29/2008 18:04:10 (1214755450)
retention_level = 3, fragment = 2, file_num = 1... (14 Replies)
Discussion started by: manalisharmabe
14 Replies
7. Shell Programming and Scripting
What is the proper way to run two commands together?
For example, in the below I would like run a command in bold then pipe that output to awk to re-format it. Thank you :).
bedtools nuc -fi /home/cmccabe/Desktop/bed/hg19.fa -bed /home/cmccabe/Desktop/bed/xgen_baits.bed >... (3 Replies)
Discussion started by: cmccabe
3 Replies
8. Shell Programming and Scripting
Dear Team
/app/Appln/logs/
echo Session used server are 'grep -i pid|grep -i session | cut -d'.' -f1 | awk '{print $9}' | sort | uniq'
Output -
lxserver01
lxserver02
lxserver03
When I grep session pid in logs server details I can see above distinct server details but I... (6 Replies)
Discussion started by: skp
6 Replies
9. Shell Programming and Scripting
I am trying to write a korn shell script (Z.ksh) that will execute three other korn shell scripts within it. The three korn shell scripts (A.ksh,B.ksh,C.ksh) each execute a series of .sas programs. A.ksh, B.ksh, and C.ksh must each wait until the last .sas program within them executes and finishes... (2 Replies)
Discussion started by: imoore
2 Replies
10. UNIX for Beginners Questions & Answers
I have a question to this command
find . -type f -name ".*txt" -exec grep "text" {}\.
The find command will locate a file name with the extension of txt once per round and find the word "text" in the content of the file or the find command will locate all the file names with the extension of... (2 Replies)
Discussion started by: TestKing
2 Replies
grep(1) General Commands Manual grep(1)
Name
grep, egrep, fgrep - search file for regular expression
Syntax
grep [option...] expression [file...]
egrep [option...] [expression] [file...]
fgrep [option...] [strings] [file]
Description
Commands of the family search the input files (standard input default) for lines matching a pattern. Normally, each line found is copied
to the standard output.
The command patterns are limited regular expressions in the style of which uses a compact nondeterministic algorithm. The command patterns
are full regular expressions. The command uses a fast deterministic algorithm that sometimes needs exponential space. The command pat-
terns are fixed strings. The command is fast and compact.
In all cases the file name is shown if there is more than one input file. Take care when using the characters $ * [ ^ | ( ) and in the
expression because they are also meaningful to the Shell. It is safest to enclose the entire expression argument in single quotes ' '.
The command searches for lines that contain one of the (new line-separated) strings.
The command accepts extended regular expressions. In the following description `character' excludes new line:
A followed by a single character other than new line matches that character.
The character ^ matches the beginning of a line.
The character $ matches the end of a line.
A . (dot) matches any character.
A single character not otherwise endowed with special meaning matches that character.
A string enclosed in brackets [] matches any single character from the string. Ranges of ASCII character codes may be abbreviated
as in `a-z0-9'. A ] may occur only as the first character of the string. A literal - must be placed where it can't be mistaken as
a range indicator.
A regular expression followed by an * (asterisk) matches a sequence of 0 or more matches of the regular expression. A regular
expression followed by a + (plus) matches a sequence of 1 or more matches of the regular expression. A regular expression followed
by a ? (question mark) matches a sequence of 0 or 1 matches of the regular expression.
Two regular expressions concatenated match a match of the first followed by a match of the second.
Two regular expressions separated by | or new line match either a match for the first or a match for the second.
A regular expression enclosed in parentheses matches a match for the regular expression.
The order of precedence of operators at the same parenthesis level is the following: [], then *+?, then concatenation, then | and new
line.
Options
-b Precedes each output line with its block number. This is sometimes useful in locating disk block numbers by context.
-c Produces count of matching lines only.
-e expression
Uses next argument as expression that begins with a minus (-).
-f file Takes regular expression (egrep) or string list (fgrep) from file.
-i Considers upper and lowercase letter identical in making comparisons and only).
-l Lists files with matching lines only once, separated by a new line.
-n Precedes each matching line with its line number.
-s Silent mode and nothing is printed (except error messages). This is useful for checking the error status (see DIAGNOSTICS).
-v Displays all lines that do not match specified expression.
-w Searches for an expression as for a word (as if surrounded by `<' and `>'). For further information, see only.
-x Prints exact lines matched in their entirety only).
Restrictions
Lines are limited to 256 characters; longer lines are truncated.
Diagnostics
Exit status is 0 if any matches are found, 1 if none, 2 for syntax errors or inaccessible files.
See Also
ex(1), sed(1), sh(1)
grep(1)