The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
using Grep for only a certain number of columns MaestroRage UNIX for Dummies Questions & Answers 2 02-13-2008 02:24 AM
How to grep a number in a file to find them in another file ahjiefreak Shell Programming and Scripting 7 12-12-2007 06:01 AM
Grep a number from a line in ksh rodluo Shell Programming and Scripting 3 12-09-2007 09:31 AM
Finding number ranges using grep DKNUCKLES Shell Programming and Scripting 2 11-07-2007 02:30 AM
Rename a number of files using grep TylerDurden UNIX for Dummies Questions & Answers 4 11-24-2003 03:12 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 12-11-2007
ahjiefreak ahjiefreak is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 132
How to grep a number in a file name

Hi,

I have multiple files where it starts with test1.c, test2.c,test3.c and so on.

I would like to get each file separately to perform abstraction from these files.

I tried something like:-

for t in ./*
filenumber=${t:4} # to cut the "test" in order to get the number

cat test$filenumber.c| sed 's/^[ ]*//' >final.txt

However, in my folder, there is other potential file other than test1.c,test2.c...in other words, there are other files in the folder.

Is there other better way to grab the number so that each file can be catenate automatically?


Please advise. Thanks.


-Jason
 

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 07:28 PM.


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