9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need to find two matches in the output from ps. I am searching with ps -ef |grep mysql for:
my.cnf
/bin/sh /usr/bin/mysqld_safe --defaults-file=/data/mysql/master/agis_core/etc/my.cnf
after this match I want to search back and match the hostname which is x number of lines back, above the... (2 Replies)
Discussion started by: bash_in_my_head
2 Replies
2. Shell Programming and Scripting
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
3. UNIX for Dummies Questions & Answers
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies
4. UNIX for Advanced & Expert Users
Hi, everyone.
I need to write a program to get io info based on libperfstat.
But the "write time" of a disk is just half of the value get from iostat.
I'm confused and can't explain. Help please.
How I calculate "write service time per sec":
In iostat:
write service... (0 Replies)
Discussion started by: jackliang
0 Replies
5. Shell Programming and Scripting
Please see the following code, why "aab" matchs "ab" when using reglar expression ?
$ ] && echo "ok" || echo "error";
ok
$ ] && echo "ok" || echo "error";
error
$ ] && echo "ok" || echo "error";
error
$ ] && echo... (8 Replies)
Discussion started by: 915086731
8 Replies
6. Shell Programming and Scripting
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Discussion started by: shis100
7 Replies
7. Shell Programming and Scripting
hello,
I am writting a regular expression that intend to match any tunnel or serial interface but it doesn't mtach any serial sub-interface.
For example, statement should match "Tunnel3" or "Serial0/1" but shouldn't match "Serial0\1.1" (doesn't include dot ".")
I tried the following but... (3 Replies)
Discussion started by: ahmed_zaher
3 Replies
8. Shell Programming and Scripting
I have 2000 files named like "file-fr0000.log", "file-fr1999.log"...
I wanna generate the file names automatically in the following c shell script:
set fr = 0
while ($fr <= 1999)
grep "ENERGY" file-fr$fr.log > data.dat
@ fr = ( $fr + 1 )
end
The above will generate file names... (3 Replies)
Discussion started by: rockytodd
3 Replies
9. Linux
Regular expression to extract "y" from "abc/x.y.z" (2 Replies)
Discussion started by: rag84dec
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)