Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Get all File names starting with letter P

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-16-2011
prassu prassu is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 16 May 2011, 6:42 PM EDT
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Get all File names starting with letter P

Hi,
I have lets say 10 files , I need to process them one by one.
So I need a command to get one file name at a time to process it into a variable

Example
Files
P1111.dat
P3344.dat
S344.dat
...

v_file_name = 'p111.dat' .. I will rename it to something after processing

second iteration v_file_name = p3344.dat

Etc.

Thanks would really appreciate your help

---------- Post updated at 02:42 PM ---------- Previous update was at 01:42 PM ----------

Never mind got it


Code:
cd $HOME
for file in $HOME/[pP]*.*
do 
  echo $file 
done


Last edited by Franklin52; 05-17-2011 at 02:36 AM.. Reason: Please use code tags
Sponsored Links
    #2  
Old Unix and Linux 05-16-2011
KenJackson KenJackson is offline
Registered User
 
Join Date: May 2008
Last Activity: 7 September 2011, 6:25 AM EDT
Location: Maryland, USA
Posts: 307
Thanks: 2
Thanked 29 Times in 21 Posts
Your solution works if all the files have a period in the name.

If you want it to work even on files with no period, use: $HOME/[pP]*
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep for filetype starting with letter p alindner Homework & Coursework Questions 3 04-02-2011 08:11 PM
sort lines in different files based on the starting letter jathin12 UNIX for Dummies Questions & Answers 1 09-18-2009 05:54 AM
Shell - Matching 3 letter file names PrasannaKS Shell Programming and Scripting 4 12-30-2008 01:37 PM
Sum of Files Sizes starting with a letter... pbsrinivas Shell Programming and Scripting 2 07-25-2007 08:21 AM
how to find capital letter names in a file without finding words at start of sentence kev269 Shell Programming and Scripting 1 04-10-2006 09:35 PM



All times are GMT -4. The time now is 03:25 AM.