Sponsored Content
Full Discussion: Regular Expression question
Top Forums UNIX for Dummies Questions & Answers Regular Expression question Post 302195242 by era on Wednesday 14th of May 2008 03:18:01 PM
Old 05-14-2008
If including the last directory component as well is acceptable then you can do [^/]*/[^/]*$ to get the last and the penultimate directory (#1 and half #2) and then if you trim #1 and the last slash, you get the real answer for #2.

*? is certainly not a plain old grep regular expression.

What's the point of this exercise?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

question about regular expression

why does * highlight everything in it... shouldn't it only highlight capital letters? (0 Replies)
Discussion started by: brentdeback
0 Replies

2. UNIX for Dummies Questions & Answers

Regular Expression Question

Hi - I am trying to ignore the following items from a list. lp0 lp11 lp12 lp14 The following code works fine, but I was wondering if there was a tidier way to write the lp regular expression? egrep -v "lp" Thanks in advance. (3 Replies)
Discussion started by: Krispy
3 Replies

3. Shell Programming and Scripting

Regular expression question

hi i need to wipe out something from giving path i have some thing like that : pwd | sed 's/.*foo//' it is working fine when I have path like : /blah/balh1/foo/moo so it erasing me all that comes before the foo including the foo but I have problem when I have dir by the name of... (7 Replies)
Discussion started by: umen
7 Replies

4. UNIX for Dummies Questions & Answers

question (regular expression related)

anyone knows what does this regular expression match for? \(3,\).*\1.*\1 (1 Reply)
Discussion started by: metalwarrior
1 Replies

5. UNIX for Dummies Questions & Answers

Question on Regular Expression

Folks; Could some one tell me what these 2 regular expressions mean: */(*)/* (\d\d\d\d/\d\d/\d\d/*?) (14 Replies)
Discussion started by: Katkota
14 Replies

6. Shell Programming and Scripting

Easy Perl regular expression question

Hey all! what matching expression might I use to match all characters included in \W, EXCEPT < and > ? for example: @tokens=split(/ ???? /,$string); I've dubiously tried \W but this clips off the first letter of each "token", for some reason ... (2 Replies)
Discussion started by: applefat
2 Replies

7. UNIX for Dummies Questions & Answers

a question about a regular expression

I like to loop a list of files which named file1, file2, file3, file4, etc if I like to loop them all over for f in file1, file2, file3, file4 do echo "processing" $f done how to use a regular expression to loop file$i instead? Thank you. (4 Replies)
Discussion started by: ksgreen
4 Replies

8. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

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)
Discussion started by: jessy83
1 Replies

9. UNIX for Dummies Questions & Answers

Regular Expression Question

Hello, I'm trying to rename a bunch of files that were named incorrectly. I know a little about regular expressions but I'm not very good at them. Here is the image of the file names: http://i47.tinypic.com/np2gxi.jpg I'm trying to change the 20111116 at the beginning to 20101116 for all... (2 Replies)
Discussion started by: nastyn8
2 Replies

10. UNIX for Dummies Questions & Answers

Regular expression question

Hi guys, I need a help with a query. Basically i want to know the difference between (0+01)* and ((0+01)*)* . It seems whatever string can be generated by the first RE can also be generated by second and they should essentially be same. Am i missing something? (1 Reply)
Discussion started by: srkmish
1 Replies
NIGREP(1)						      General Commands Manual							 NIGREP(1)

NAME
nigrep - search for a regular expression in the NetInfo hierarchy SYNOPSIS
nigrep expression [ -t ] domain [ directory ... ] DESCRIPTION
nigrep searches through the specified domain argument for a regular expression. It searches the domain's directory hierarchy depth-first starting from the root directory. It can also start from each directory specified on the command line. The domain argument can be specified as an absolute or relative domain name. The domain argument can be specified as a network address or hostname and tag if preceded by the -t option. On output, nigrep prints the directory ID number of the directory which contains the regular expression, and the property key and values where it was found. A line is printed for each property that contains the regular expression. OPTIONS
-t Specify domain as a network address or hostname and tag. EXAMPLES
% nigrep '[Nn]et' / % nigrep '[Nn]et' -t 192.42.172.17/local % nigrep '192.[0-9]+.172' -t astra/network /machines % nigrep '/Net/server.*/Users' .. /users /mounts SEE ALSO
netinfo(5) AUTHOR
Marc Majka, Apple Computer Inc. Apple Computer, Inc. August 9, 1994 NIGREP(1)
All times are GMT -4. The time now is 08:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy