list only identical filename


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting list only identical filename
# 1  
Old 05-10-2006
Java list only identical filename

Hi Friends,

We have four filenames with first few digits are identical.From those files, i need to pick up 2 files based on my parameter.
The following example will give more information to understand my question.

Files in the directory:

small_customer_aa.csv
small_customer_ab.csv
small_customer_relate_aa.csv
small_customer_relate_ab.csv


I'll pass the small_customer as a parameter to shell script.
My expected flenames as below

small_customer_aa.csv
small_customer_ab.csv

i'have tried to use

$ls -a small_customer*.csv

but it will give all the filenames.

Thanks in advance for your valueble solutions. Smilie

Regards,
HAA
# 2  
Old 05-10-2006
How about 'ls -a small_customer_a*'?
# 3  
Old 05-10-2006
list only identical filename

Hi Corona

i cannot pass the parameter like 'small_customer_a',

Thanks and Regards,
HAA
# 4  
Old 05-10-2006
How about 'ls -a small_customer_[a-z][a-z].csv' ?

Failing that, I'll need more information on what files should match and what files shouldn't since the available information is pretty sketchy.
# 5  
Old 05-10-2006
Hi Corona

parameter=$1

if parameter is small_customer then
expected filenames:
small_customer_aa.csv
small_customer_ab.csv
else if parameter is small_customer_relate then
small_customer_relate_aa.csv
small_customer__relate_ab.csv

end if;

how can i extract the above filenames from the directory.


Hope this will clear my requirement.

Regards,
HAA
# 6  
Old 05-10-2006
If you want only files ending _[xx].csv, you can try following
Code:
#!/bin/ksh
parameter=$1
for list in `ls ${parameter}_??.csv`
do
echo $list
done

# 7  
Old 05-17-2006
Power List only identical file name

Hi

Thanks a lot it works fine :-) Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List filename of files only inside a directory (non-recurrsive) on AIX

I wish to list only files along with the absolute path in a given directory on my AiX 6.1 system. Below is the best I could do. ls -p "/app/scripts"/* This gives a a list of all filename along with folder names with absolute path non-recurrsive (without listing files in sub-directories)... (1 Reply)
Discussion started by: mohtashims
1 Replies

2. UNIX for Dummies Questions & Answers

Output a list of five books with their filename titles into one file

Dear unix forum, could I output a list of five books with their file name titles into one file? In order o output all the contents of all the files with their file names there was: find . -type f | while read x; echo -e "\n$x";cat "$x";done > бетховен.txt In spite of them being successively... (5 Replies)
Discussion started by: Xcislav
5 Replies

3. UNIX for Dummies Questions & Answers

List files after a certain filename

Requirement: I need to ls all files based on date timestamp after a trigger file In the below example, I need to pull only files uploaded after orders.bmk by date timestamp ascending. ORDERS_0000000009877468.txt ORDERS_0000000009877464.txt ORDERS_0000000009877460.txt... (9 Replies)
Discussion started by: eskay
9 Replies

4. Shell Programming and Scripting

Help shell script to list filename file_path

HI owner date and time and size of file in a row shell script to list filename file_path i have tried the below code present_dir=`pwd` dir=`dirname $0` list=`ls -lrt | awk {'print $9,$3,$6,$7,$8'}` size=`du -h` path=`cd $dir;pwd;` printf "$list" printf "$path" printf " $size" ... (4 Replies)
Discussion started by: abiram
4 Replies

5. Windows & DOS: Issues & Discussions

Check dir for overly path+filename and list in txt

Well since Windows always laments over some of my files having a too long "path+filename" and it gets in the way of copying complete directory structures I would love to have a DOS Script that helps me with finding those. I already tried DCSoft Long Filename Finder but that is neither DOS based... (3 Replies)
Discussion started by: pasc
3 Replies

6. Shell Programming and Scripting

Using Sort with a filename list

I am using the following to script to sort and process files in order find $eventsFolder${cameraList} -mtime -365 -name \*capture.jpg > /tmp/alarmvideos/${cameraname}.list # use local time settings to order the events right. export LC_ALL=C sort /tmp/alarmvideos/${cameraname}.list -n -o... (1 Reply)
Discussion started by: ddalton
1 Replies

7. Shell Programming and Scripting

Script to List, Modify, replace filename for an upload?

Hello, here is my problem: I have ma program in a first directory dir1: ls path1/rep1/ file1.f90 file1.f90~ file1.o file2.f90 .... etc... I have modified folder in an other directory: ls path2/rep2/ file1_modified.f90 file2_modified.f90 .... etc... All files from first... (8 Replies)
Discussion started by: shadok
8 Replies

8. UNIX for Dummies Questions & Answers

deleting words in list with more than 2 identical adjacent characters

Morning Guys & Gals, I am trying to figure out a way to remove lines from a file that have more than 2 identical characters in sequence.. So if for instance the list would look like ; the output would be ; I can't seem to get my head around perl (among many other... (7 Replies)
Discussion started by: TAPE
7 Replies

9. Shell Programming and Scripting

List files with spaces in filename

I have a text file containing files in a directory structure i.e. /project/hr/raw/jcpdatav/datav_aug03 /project/hr/raw/jcpdatav/comb8121sep02n /project/hr/raw/jcpdatav/datav_feb04_ons /project/hr/raw/jcpdatav/corpsick_jun06 /project/hr/raw/jcpdatav/jcpjoiners200507... (3 Replies)
Discussion started by: mr_crosby
3 Replies

10. Shell Programming and Scripting

read a part of filename from the list in the script

how can i read a part of filename from the list in the script? all file in directory...will start with "CDBACKUPFILE" then the name is stored in list.txt such as JOHN,MARRY,PETER. After this, is seq number. CDBACKUPFILEJOHN00001 CDBACKUPFILEMARRY00004 CDBACKUPFILEPETER00003 I will use:... (3 Replies)
Discussion started by: happyv
3 Replies
Login or Register to Ask a Question