what left of the pattern


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting what left of the pattern
# 1  
Old 11-01-2006
what left of the pattern

I have a script which loop through a directory then report any file matches the given pattern,
say, the pattern is "a2006", this file would be returned
a20061101.txt
I would like to know how can I get the remaining of the filename, so
a20061101txt - a2006 = 1101.txt
Can anybody help? Thank you so much!
# 2  
Old 11-01-2006
Assuming that your filename is in the variable $filename (or something like that):
Code:
# filename=a20061101.txt
# echo ${filename#a2006}
1101.txt

You can use this in each iteration of your loop that works on the filenames.

Oh, and check the man page of ksh or bash to see how this particular thing comes about.

Last edited by blowtorch; 11-01-2006 at 10:23 PM.. Reason: extra info
# 3  
Old 11-02-2006
Code:
expr match "$filename" 'a2006\(.*\)'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find a pattern and traverse left and pick something from another pattern

I have a Text like below , Detailed Table Information Table(tableName:a1, dbName:default, owner:eedc_hdp_s_d-itm-e, createTime:1520514151, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:, location:hdfs://DBDP-Dev/apps/hive/warehouse/a1,... (6 Replies)
Discussion started by: nv186000
6 Replies

2. AIX

How much resources is left on the P7?

I know that it is possible to login into the HMC console and view all the specs like, how much CPU/RAM every LPAR has. But how can I check how much the whole P7 has in total and how much is left to creat a new LPAR:wall: (5 Replies)
Discussion started by: DiViN3
5 Replies

3. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

4. Shell Programming and Scripting

File count from where it left??

i have this code num=1 dat10=`date "+%m/%d/%Y" -d "+10 days"` dat=`date "+%m/%d/%Y"` set -x grep "text=.&" /root/Softwares/apache-tomcat-5.5.30/logs/catalina.out|awk -F"from=" '{print $2}'|awk -F"opid" '{print $1}'|sort|uniq > pnos while read line do psql -U poss -d emsver -c "insert into... (3 Replies)
Discussion started by: nikhil jain
3 Replies

5. Shell Programming and Scripting

using cut command right to left

Hi guys I have variable that contains a full directory path. var=/tmp/a/b/c/d I want to be able to extract different directories in the path right to left while using / as the delimiter. so for e.g. if in the above example if I want c then I want it to be in the middle of 1st and... (2 Replies)
Discussion started by: alinaqvi90
2 Replies

6. Shell Programming and Scripting

search a pattern and if pattern found insert new pattern at the begining

I am trying to do some thing like this .. In a file , if pattern found insert new pattern at the begining of the line containing the pattern. example: in a file I have this. gtrow0unit1/gctunit_crrownorth_stage5_outnet_feedthru_pin if i find feedthru_pin want to insert !! at the... (7 Replies)
Discussion started by: pitagi
7 Replies

7. Solaris

No space left on device

Hi all, A very strange problem I have this morning with my Solaris 8. I have a FS full, I deleted some files but the system doesn't seems to reallocate the free space (I'm using Veritas): df -k : /dev/vx/dsk/dlds02vg/dlds02oralv 4194304 4194304 0 100% /dlds02/lds/oracle ... (4 Replies)
Discussion started by: unclefab
4 Replies

8. Shell Programming and Scripting

How to get the most left hand string ??

Hi, I remember once seeing a way to get the left most string in a word. Let's say: a="First.Second.Third" (separated by dot) echo ${a#*.} shows --> Second.Third echo ${a##*.} shows --> Third How do I get the the left most string "First" Or "First.Second" ??? Tried to replace #... (2 Replies)
Discussion started by: jfortes
2 Replies

9. UNIX for Dummies Questions & Answers

How much disk space left?

Hi, I need to allocate some space to a particular filesystem. I am Unix newbie ... please tell me how to find out how much disk space I have on a disk. I use df -b to check kb free on the filesystems. Then I thought I would use pvdisplay -v /dev/dsk/c5t2d6 but I couldn't work out how much... (1 Reply)
Discussion started by: gummysweets
1 Replies

10. UNIX for Advanced & Expert Users

no space left on device

I have a SCO UNIX on my Server. When I last tried to shutdown my system, I got an error message “no space left on device”. Now when I try to boot the system again, I just can't and I get the same error message. Please help! (2 Replies)
Discussion started by: anjane
2 Replies
Login or Register to Ask a Question