How to find single file of any task_id?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to find single file of any task_id?
# 8  
Old 01-31-2015
The sample you posted can't possibly be the contents of one single directory as there are duplicate filenames in it. If you want one task id listed regardless of the numerical suffix, try
Code:
sort -ut"-" -k1,1 file
sms_task_id_01-12345.csv
sms_task_id_02-12345.csv
sms_task_id_03-12345.csv

# 9  
Old 02-01-2015
We are not getting desire output:
my position is now:
Quote:
pwd
/ap2/base/generate/

ls -lrth
sms_task_id_01-13345.csv
sms_task_id_01-14345.csv
sms_task_id_01-14345.csv
sms_task_id_02-12345.csv
sms_task_id_02-13345.csv
sms_task_id_02-14345.csv
sms_task_id_03-12345.csv
sms_task_id_03-13345.csv
sms_task_id_03-14345.csv
Now we want any single file according task_id like:
Quote:
sms_task_id_01-12345.csv
sms_task_id_02-12345.csv
sms_task_id_03-12345.csv
# 10  
Old 02-01-2015
Well then try :
Code:
ls -rt | awk -F- '!A[$1]++'

# 11  
Old 02-01-2015
Actually our file is like:
Code:
pwd
/ap2/base/generate/

ls -lrth
sms_task_id_01-13345.ab.csv
sms_task_id_01-14345.bc.csv
sms_task_id_01-14345.ce.csv
sms_task_id_02-12345.ae.csv
sms_task_id_02-13345.af.csv
sms_task_id_02-14345.ag.csv
sms_task_id_03-12345.ba.csv
sms_task_id_03-13345.al.csv
sms_task_id_03-14345.ai.csv

I want output:
Code:
sms_task_id_01-13345.ab.csv
sms_task_id_02-12345.ae.csv
sms_task_id_03-12345.ba.csv

Need one-one any file for task_id_01, task_id_02 & task_id_03

Last edited by Don Cragun; 02-01-2015 at 03:31 AM.. Reason: Change QUOTE tags to CODE tags.
# 12  
Old 02-01-2015
So you have a file that contains these strings:
Code:
pwd
/ap2/base/generate/

ls -lrth
sms_task_id_01-13345.ab.csv
sms_task_id_01-14345.bc.csv
sms_task_id_01-14345.ce.csv
sms_task_id_02-12345.ae.csv
sms_task_id_02-13345.af.csv
sms_task_id_02-14345.ag.csv
sms_task_id_03-12345.ba.csv
sms_task_id_03-13345.al.csv
sms_task_id_03-14345.ai.csv

And the file names start on the fifth line, is that what you are saying?

Have you tried any of the commands. What is your result?
# 13  
Old 02-01-2015
Are you reading the posts? Applying them? Adapting them?
Code:
sort -ut"-" -k1,1 file
sms_task_id_01-13345.ab.csv
sms_task_id_02-12345.ae.csv
sms_task_id_03-12345.ba.csv

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Paste 2 single column files to a single file

Hi, I have 2 csv/txt files with single columns. I am trying to merge them using paste, but its not working.. output3.csv: flowerbomb everlon-jewelry sofft steve-madden dolce-gabbana-watchoutput2.csv: http://www1.abc.com/cms/slp/2/Flowerbomb http://www1.abc.com/cms/slp/2/Everlon-Jewelry... (5 Replies)
Discussion started by: ajayakunuri
5 Replies

2. UNIX for Dummies Questions & Answers

To find and display the middle line in a file using single line command.

Hi all, How can i display the middle line of a file using a single line command? (6 Replies)
Discussion started by: Lakme Pemmaiah
6 Replies

3. Shell Programming and Scripting

Using a single "find" cmd to search for multiple file types and output individual files

Hi All, I am new here but I have a scripting question that I can't seem to figure out with the "find" cmd. What I am trying to do is to only have to run a single find cmd parsing the directories and output the different file types to induvidual files and I have been running into problems.... (3 Replies)
Discussion started by: swaters
3 Replies

4. Shell Programming and Scripting

how to find first files in a directory and combine them as a single file?

i have below list of files in a directory. /root/admin/files/file1.txt /root/admin/files/file2.txt /root/admin/files/file3.txt /root/admin/files/pattern.txt /root/admin/files/server.txt i need combine the above text files in the below sequence, file1.txt, pattern.txt,server.txt =>... (8 Replies)
Discussion started by: vel4ever
8 Replies

5. Shell Programming and Scripting

Find all the files under a specific directory and zip them into a single file.

Hi, Is there a way to find all the files from a specific location and then zip them into a single file, even if they are in multiple directories? (3 Replies)
Discussion started by: rudoraj
3 Replies

6. Shell Programming and Scripting

wanted to find both link file and ordinary file using single find command

find . -type fl o/p is only the ordinary file. where in it wont give the link files. (2 Replies)
Discussion started by: nikhil jain
2 Replies

7. Shell Programming and Scripting

Script to multiple find and replace in a single file

Dear all I need a script for multiple find and replace in a single file. For example input file is - qwe wer ert rty tyu asd sdf dgf dfg fgh qwe wer det rtyyui jhkj ert asd asd dfgd now qwe should be replace with aaaaaa asd should be replace with bbbbbbbb rty should be replace... (6 Replies)
Discussion started by: wildhorse
6 Replies

8. Shell Programming and Scripting

unzip single file and untar single file

Dear friends, My requirement below- 1] I have a zip file on unix server - ETL_Extracts_20100218175009.zip which is composed of various entity extracts namely... ENTITY1.txt, ENTITY2.txt, ENTITY3.txt etc.... How do I unzip only a single file ..say ENTITY2.txt from this zip file. CAn you... (2 Replies)
Discussion started by: sureshg_sampat
2 Replies

9. Solaris

Find files older than x days and create a consolidated single tar file.

Hello, I need help in finding files older than x days and creating a single consolidated tar file combining them. Can anyone please provide me a script? Thanks, Dawn (3 Replies)
Discussion started by: Dawn Bosch
3 Replies

10. Shell Programming and Scripting

Find the size of a single specific file

As I'm a newbie to UNIX, very newbie in fact, could anyone humour me and tell me how I'd find just the file size in bytes for a specific file? Or at least just the specific line from the ls -a for the file - call it file1 I know this sounds bad but I don't seem to be getting very far at this... (3 Replies)
Discussion started by: nortypig
3 Replies
Login or Register to Ask a Question