03-09-2010
Hi,
Thanks for your reply. But I am getting syntax error for first 3 lines in bash shell. I think If we do search line by line it is taking too much of time since input file is big. Is there any way to do using awk or sed command?
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Ok, I'm stumped and can't seem to find relevant info.
(I'm not even sure, I might have asked something similar before.):
I'm trying to use shell scripting/UNIX commands to extract URLs from a fairly large web page, with a view to ultimately wrapping this in PHP with exec() and including the... (2 Replies)
Discussion started by: ropers
2 Replies
2. Shell Programming and Scripting
Hi,
Need to extract a string from one file and search the same in other files.
Ex:
I have file1 of hundred lines with no delimiters not even space.
I have 3 more files.
I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
Discussion started by: mohancrr
1 Replies
3. Shell Programming and Scripting
i have been doing this script to match every line in a current log file (access_log) with strings that i list from a path (consist of 100 of user's name ex: meggae )..
and then make a directory of every string from the text file (/path/meggae/) --->if it matched..
then print every line from the... (3 Replies)
Discussion started by: meggae
3 Replies
4. UNIX for Dummies Questions & Answers
Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string.
Previously, I was outputting just each paragraph with that search string with:
cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I would like to comment a line that matched a string "sreenivas" in a file without opening it.
Thanks in advance.
Regards,
Sreenivas (3 Replies)
Discussion started by: raosr020
3 Replies
6. Shell Programming and Scripting
Hello,
I have a file which has the below contents :
VG_name LV_name LV_size in MB LV_option LV_mountpoint owner group y
testdg rahul2lv 10 "-A y -L" /home/abc2 ... (6 Replies)
Discussion started by: rahul2662
6 Replies
7. UNIX for Beginners Questions & Answers
How to grep for searching a string within a begin and end pattern of a file.
Sent from my Redmi 3S using Tapatalk (8 Replies)
Discussion started by: Baishali
8 Replies
8. Shell Programming and Scripting
i am having file like this
#!/bin/bash
read -p 'Username: ' uservar
match='<color="red" />'
text='this is only a test
so please be patient
<color="red" />'
echo "$text" | sed "s/$match/&$uservar\g"
so desireble output what i want is if user type MARIA
this is only a test
so please... (13 Replies)
Discussion started by: tomislav91
13 Replies
9. UNIX for Beginners Questions & Answers
Text in input file is like this
<title>
<band height="21" isSplitAllowed="true" >
<staticText>
<reportElement
x="1"
y="1"
width="313"
height="20"
key="staticText-1"/>
<box></box>
<textElement>
<font fontName="Arial" pdfFontName="Helvetica-Bold"... (4 Replies)
Discussion started by: aankita30
4 Replies
GREP(1) General Commands Manual GREP(1)
NAME
grep - search a file for a pattern
SYNOPSIS
grep [ option ... ] pattern [ file ... ]
DESCRIPTION
Grep searches the input files (standard input default) for lines (with newlines excluded) that match the pattern, a regular expression as
defined in regexp(6). Normally, each line matching the pattern is `selected', and each selected line is copied to the standard output.
The options are
-c Print only a count of matching lines.
-h Do not print file name tags (headers) with output lines.
-i Ignore alphabetic case distinctions. The implementation folds into lower case all letters in the pattern and input before interpre-
tation. Matched lines are printed in their original form.
-l (ell) Print the names of files with selected lines; don't print the lines.
-L Print the names of files with no selected lines; the converse of -l.
-n Mark each printed line with its line number counted in its file.
-s Produce no output, but return status.
-v Reverse: print lines that do not match the pattern.
Output lines are tagged by file name when there is more than one input file. (To force this tagging, include /dev/null as a file name
argument.)
Care should be taken when using the shell metacharacters $*[^|()= and newline in pattern; it is safest to enclose the entire expression in
single quotes '...'.
SOURCE
/sys/src/cmd/grep.c
SEE ALSO
ed(1), awk(1), sed(1), sam(1), regexp(6)
DIAGNOSTICS
Exit status is null if any lines are selected, or non-null when no lines are selected or an error occurs.
GREP(1)