The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need Regular expression svenkatareddy Shell Programming and Scripting 4 08-17-2009 01:08 PM
Regular Expression Help sickboy Shell Programming and Scripting 8 04-04-2009 06:58 PM
regular expression jaber87 Shell Programming and Scripting 3 06-05-2008 04:07 AM
What does the regular expression ['(^[^~]+~).*'] mean? anupamar High Level Programming 2 10-29-2007 04:41 AM
Regular Expression + Aritmetical Expression Z0mby Shell Programming and Scripting 2 05-21-2002 11:59 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-02-2009
jimmy_y jimmy_y is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 94
regular expression go into a folder

Hi Everyone,

I have two folders /root/jul/a.txt and /root/july/a.txt. I have $month="jul", so use this methold, i only can go into the first folder. is there any way, i can do like $month="jul*", means can go to both folders? becuase the month folder, sometimes is jul, or july, or nov, november, or nove, or even NOVE, NOV. How to handle this case.

Thanks
  #2 (permalink)  
Old 4 Weeks Ago
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,641
You can't go to "two folders", because you can only be at one place at a time - thats true for physics as well as Unix. ;-))

What you can do is to go to one folder after the other. Here is an example script:


Code:
#!/bin/ksh

month="jul"
dir=""

ls -ld "/root/${month}*" | while read dir ; do
     cd "$dir"
     print - "now in directory: $PWD"
     ls -l
     print - "---------------"
     cd -
done

I hope this helps.

bakunin
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:23 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0