10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to remove lines in the target.txt file if $5 before the - in that file matches sorted_list. I have tried grep and awk. Thank you :).
grep
grep -v -F -f targets.bed sort_list
grep -vFf sort_list targets
awk
awk -F, '
> FILENAME == ARGV {to_remove=1; next}
> ! ($5 in... (2 Replies)
Discussion started by: cmccabe
2 Replies
2. Shell Programming and Scripting
Hi
I have a txt file and I would like to use egrep without using -v option to exclude the lines which matches with multiple Strings.
Let's say I have some text in the txt file. The command should not fetch lines if they have strings something like
CAT MAT DAT
The command should fetch me... (4 Replies)
Discussion started by: Sathwik
4 Replies
3. Shell Programming and Scripting
i had requirement like i need to get "error" line of above 3 and below 3 from a file .I tried with the below script.But it's not working.
y='grep -n -i error /home/file.txt|cut -c1'
echo $y
head -$y /home/file.txt| tail -3 >tmp.txt
tail -$y /home/file.txt head -3 >>tmp.txt (4 Replies)
Discussion started by: bhas85
4 Replies
4. Shell Programming and Scripting
Hi
I have below script which is used to grep specific errors and if error string matches send an email alert.
Script is working fine , however , i wish to print next 10 lines of the string match to get the details of error in the email alert
Current code:-
#!/bin/bash
tail -Fn0 --retry... (2 Replies)
Discussion started by: neha0785
2 Replies
5. Shell Programming and Scripting
Hi,
I'm attempting to rename some files that have spaces in them. Without linking sed commands together is it possible to replace the first three "." to " ".
File.name.is.long.ext -> File name is long.ext
I can get the desired effect with
echo "File.name.is.long.ext" | sed 's/\./ /g;s/... (5 Replies)
Discussion started by: vectox
5 Replies
6. Shell Programming and Scripting
File
6 dbnawldb010-b office Memphis_Corp_SQL_Diff Memphis-Corp-SQL-Inc-Application-Backup 03/09/11 03:24:04
42 luigi-b IPNRemitDB Memphis_Corp_SQL_Diff Memphis-Corp-SQL-Inc-Application-Backup 03/10/11 00:41:36
6 ebs-sqldev1-b IPNTracking Memphis_Corp_SQL_Diff... (4 Replies)
Discussion started by: ajiwww
4 Replies
7. Shell Programming and Scripting
I have one comma separated file (a.txt) with two or more records all matching except for the last column.
I would like to merge all matching lines into one and consolidate the last column, separated by ":". Does anyone know of a way to do this easily?
I've searched the forum but most talked... (6 Replies)
Discussion started by: giannicello
6 Replies
8. Shell Programming and Scripting
Hello,
I am searching all over the place for this, just not finding anything solid :(
I want to do be able to access the groups that are matched with grep (either with extended regex, or perl compatible regex). For instance:
echo "abcd" | egrep "a(b(c(d)))"
Of course this returns... (1 Reply)
Discussion started by: Rhije
1 Replies
9. Shell Programming and Scripting
Howdy.
I know this is most likely possible using sed or awk or grep, most likely a combination of them together, but how would one go about running a grep like command on a file where you only try to match your pattern to the second field in a line, space delimited?
Example:
You are... (3 Replies)
Discussion started by: LordJezoX
3 Replies
10. Shell Programming and Scripting
I am attempting to convert rewrite rules to Nginx, and since due to the mass amount of rewrites we must convert, I've been trying to write a script to help me on a specific part, easily.
So far I have this:
rewrite ^action/static/(+)/$ staticPage.php?pg=$1&%$query_string;
What I want done... (5 Replies)
Discussion started by: EXT3FSCK
5 Replies
GREP(1) General Commands Manual GREP(1)
NAME
grep, egrep, fgrep - search a file for a pattern
SYNOPSIS
grep [ option ] ... expression [ file ] ...
egrep [ option ] ... [ expression ] [ file ] ...
fgrep [ option ] ... [ strings ] [ file ]
DESCRIPTION
Commands of the grep family search the input files (standard input default) for lines matching a pattern. Normally, each line found is
copied to the standard output; unless the -h flag is used, the file name is shown if there is more than one input file.
Grep patterns are limited regular expressions in the style of ed(1); it uses a compact nondeterministic algorithm. Egrep patterns are full
regular expressions; it uses a fast deterministic algorithm that sometimes needs exponential space. Fgrep patterns are fixed strings; it
is fast and compact.
The following options are recognized.
-v All lines but those matching are printed.
-c Only a count of matching lines is printed.
-l The names of files with matching lines are listed (once) separated by newlines.
-n Each line is preceded by its line number in the file.
-b Each line is preceded by the block number on which it was found. This is sometimes useful in locating disk block numbers by con-
text.
-s No output is produced, only status.
-h Do not print filename headers with output lines.
-y Lower case letters in the pattern will also match upper case letters in the input (grep only).
-e expression
Same as a simple expression argument, but useful when the expression begins with a -.
-f file
The regular expression (egrep) or string list (fgrep) is taken from the file.
-x (Exact) only lines matched in their entirety are printed (fgrep only).
Care should be taken when using the characters $ * [ ^ | ? ' " ( ) and in the expression as they are also meaningful to the Shell. It is
safest to enclose the entire expression argument in single quotes ' '.
Fgrep searches for lines that contain one of the (newline-separated) strings.
Egrep accepts extended regular expressions. In the following description `character' excludes newline:
A followed by a single character matches that character.
The character ^ ($) matches the beginning (end) of a line.
A . 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 * (+, ?) matches a sequence of 0 or more (1 or more, 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 newline 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 [] then *+? then concatenation then | and newline.
SEE ALSO
ed(1), sed(1), sh(1)
DIAGNOSTICS
Exit status is 0 if any matches are found, 1 if none, 2 for syntax errors or inaccessible files.
BUGS
Ideally there should be only one grep, but we don't know a single algorithm that spans a wide enough range of space-time tradeoffs.
Lines are limited to 256 characters; longer lines are truncated.
GREP(1)