Get all File names starting with letter P


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get all File names starting with letter P
# 1  
Old 05-16-2011
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 03:36 AM.. Reason: Please use code tags
# 2  
Old 05-16-2011
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]*
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to grep a line not starting with # from a file (there are two lines starting with # and normal)?

e.g. File name: File.txt cat File.txt Result: #INBOUND_QUEUE=FAQ1 INBOUND_QUEUE=FAQ2 I want to get the value for one which is not commented out. Thanks, (3 Replies)
Discussion started by: Tanu
3 Replies

2. UNIX for Dummies Questions & Answers

Sort alphabetically starting from specified letter

Hi. I'm trying to sort a list of items in a file alphabetically but starting from the letter 'X'. For instance if I had the following file; test.txt Z A T W Y B S X I would like the output to look like; X Y (8 Replies)
Discussion started by: mmab
8 Replies

3. Shell Programming and Scripting

Replace specific letter in a file by other letter

Good afternoon all, I want to ask how to change some letter in my file with other letter in spesific line eg. data.txt 1 1 1 0 0 0 0 for example i want to change the 4th line with character 1. How could I do it by SED or AWK. I have tried to run this code but actually did not... (3 Replies)
Discussion started by: weslyarfan
3 Replies

4. Shell Programming and Scripting

Exclude certain file names while selectingData files coming in different names in a file name called

Data files coming in different names in a file name called process.txt. 1. shipments_yyyymmdd.gz 2 Order_yyyymmdd.gz 3. Invoice_yyyymmdd.gz 4. globalorder_yyyymmdd.gz The process needs to discard all the below files and only process two of the 4 file names available ... (1 Reply)
Discussion started by: dsravanam
1 Replies

5. Homework & Coursework Questions

Grep for filetype starting with letter p

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Which files in /usr/bin whose names begin with “p” are python scripts? Store the numbered results in... (3 Replies)
Discussion started by: alindner
3 Replies

6. UNIX for Dummies Questions & Answers

sort lines in different files based on the starting letter

Hi ,, i have the below file... D 2342135 B 214236 C argjlksd V lskjrghaklsr C slkrgj B sdg4tsd E aslkgjlkasg i want to sort the lines into different files based on the starting letter of the line. so that i have different files for lines starting with a letter. thanks (1 Reply)
Discussion started by: jathin12
1 Replies

7. Shell Programming and Scripting

Shell - Matching 3 letter file names

Hi I am running a shell script with bdf command and want to match all files with length 3 inside a specific partitions. How do i do that say for example if i want to list all files with length 3 in /home/jimmy partition, bdf /home/jimmy the output i need is xyx abc yyy amp ... (4 Replies)
Discussion started by: PrasannaKS
4 Replies

8. UNIX for Dummies Questions & Answers

Listing all the files names not starting as

hello all, iam new to shell scripting.I have searched the forum and could'nd find a close enough answer and hence this post: I want to list all the file names whose names don't start as abc. For example if my folder constains files with names: abc123.txt,erdf23.rdf,ed45r.fmb i want a... (13 Replies)
Discussion started by: valluvan
13 Replies

9. Shell Programming and Scripting

Sum of Files Sizes starting with a letter...

Can we find some of size of all files in a directry where file names start with an letter t* the out put of ls -ls t* is 4 -rw-r--r-- 1 root system 61 Jul 03 10:56 t 4 -rw-r--r-- 1 root system 3146 Jul 19 11:11 t1 4 -rw-r--r-- 1 root system ... (2 Replies)
Discussion started by: pbsrinivas
2 Replies

10. Shell Programming and Scripting

how to find capital letter names in a file without finding words at start of sentence

Hi, I want to be able to list all the names in a file which begin with a capital letter, but I don't want it to list words that begin a new sentence. Is there any way round this? Thanks for your help. (1 Reply)
Discussion started by: kev269
1 Replies
Login or Register to Ask a Question