Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Get all File names starting with letter P

Shell Programming and Scripting

Thread Tools Search this Thread Display Modes
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

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


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

second iteration v_file_name = p3344.dat


Thanks would really appreciate your help

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

Never mind got it

cd $HOME
for file in $HOME/[pP]*.*
  echo $file 

Last edited by Franklin52; 05-17-2011 at 03:36 AM.. Reason: Please use code tags
Sponsored Links
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

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 09:11 PM
sort lines in different files based on the starting letter jathin12 UNIX for Dummies Questions & Answers 1 09-18-2009 06:54 AM
Shell - Matching 3 letter file names PrasannaKS Shell Programming and Scripting 4 12-30-2008 02:37 PM
Sum of Files Sizes starting with a letter... pbsrinivas Shell Programming and Scripting 2 07-25-2007 09: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 10:35 PM

All times are GMT -4. The time now is 04:05 AM.