This is my first post so, Hello World! Anyways, I'm learning how to use unix and its quickly become apparent that a strong foundation in regular expressions will make things easier. I'm not sure if my syntax is messing things up or my logic is messing things up.
So, I want a list of most of the current processes ps -e generates a list similar to the one below but with more lines.
Pattern: I want to reduce the output to only include lines that have numbers greater than 1000.
Program: I'll use grep to print the lines matching the above pattern.
Options: I don't think I need to use any options.
Regular Expression: \b[1-9][0-9]\{3,}\b
File: ps -e (omitted)
Again the fully command line argument(?correct term) is:
I read the regular expression as:
\b: Check for world boundary before the string.
[1-9]: The first character in the string must be between 1 and 9.
[0-9]: The second character in the string must be between 0 and 9.
\{3,}: Replaces the above statement with: The characters following the first match must match between 0 and 9 at least 3 more times.
Kinda would look like \b[1-9][0-9][0-9][0-9]\b (for the min)
\bCheck for word boundary at the end of the string.
The return I get is:
Quote:
grep: Unmatched \{
I'm probably missing something simple but I can't figure it out.
And then you could leave out the comma too:
or even 4 characters that are no space.
( and since the first field is right aligned and the max pid is 99999:
or filter out lines that start with two spaces:
but that is stretching it a little and probably not very portable )
Last edited by Scrutinizer; 10-11-2009 at 07:59 PM..
I've found this script which seems very promising to solve my issue:
To search and replace many different database passwords in many different (.php, .pl, .cgi, etc.) files across my filesystem.
The passwords may or may not be contained within quotes, single quotes, etc.
#!/bin/bash... (4 Replies)
Hi all,
How am I read a file, find the match regular expression and overwrite to the same files.
open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat";
open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat";
while (<DESTINATION_FILE>)
{
# print... (1 Reply)
Hi,
I am executing a svnlook command to check to see if the following line exists. I need a regular expression to represent the line.
A /test/test1/qa/test2/index.html
A /test/test1/qa/test3/test.jpg
A /test/test1/qa/test3/test1.jpg
A /test/test1/qa/test4/test.swf
I just need to extract... (9 Replies)
Hello,
I'm working on learning regular expressions and what I can do with them. I'm using unix to and its programs to experiment and learn what my limitations are with them.
I'm working on duplicating the regular expression:
^(.*)(\r?\n\1)+$
This is supposed to delete duplicate lines... (2 Replies)
I have the following code:
ls -al /bin | tr -s ' ' | grep 'x'
ls -al: Lists all the files in a given director such as /bin
tr -s ' ': removes additional spaces between characters so that there is only one space
grep 'x': match all "x" characters that are followed by a whitespace.
I was... (3 Replies)
please can someone tell me what the following regrex means
grep "^aa*$" <file>
I thought this would match any word beginning with aa and ending with $, but it doesnt.
Thanks in advance
Calypso (7 Replies)
Hi, guys. I have one question, hope somebody can give me a hand
I have a file called passwd, the contents of it arebelow:
***********************
...
goldsimj:x:5008:200:
goldsij2:x:5009:200:
whitej:x:5010:201:
brownj:x:5011:202:
goldsij3:x:5012:204:
greyp:x:5013:203:
...... (6 Replies)
When i do ls -ld RT_BP* i am getting the following list.
drwxrwx--- 2 user group 256 Oct 17 10:09 RT_BP809
drwxrwx--- 2user group 256 Oct 17 10:09 RT_BP809.O
drwxrwx--- 2 user group 256 Oct 17 10:09 RT_BP810
drwxrwx--- 2user group 256 Oct... (2 Replies)
guys,
my requirment goes like this:
I have a file, and wish to filter out records where
1. The first letter is o or O
and
2. The next 4 following letter should not be ther
I do not wish to use pipe and wish to do it in one shot.
The best expression I came up with is:
grep ^*... (10 Replies)