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?
# 1  
Old 01-31-2015
How to find single file of any task_id?

Hi Guys,


I have many files names of single task_id, now we have to find out only file of every task_id, my files is following :-


Code:
sms_task_id_01-12345.csv
sms_task_id_01-12345.csv
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

Output should be single files from each task_id like below

Code:
sms_task_id_01-12345.csv
sms_task_id_02-13345.csv
sms_task_id_03-13345.csv


where task_id is like (task_id_01, task_id_02, task_id_03)

How to find single file of any task_id

Last edited by Scrutinizer; 01-31-2015 at 04:35 AM.. Reason: code tags, removed quote tags
# 2  
Old 01-31-2015
What's missing is why / on what basis you want to select a file for a task id. For example for sms_task_id_01 it is the forst one, for sms_task_id_02 and 03 it is the middle one. In aother words, what is the logic?
This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 01-31-2015
I need any one files of task_id_01 like wise task_id_02, task_id_03

Quote:
Originally Posted by Scrutinizer
What's missing is why / on what basis you want to select a file for a task id. For example for sms_task_id_01 it is the forst one, for sms_task_id_02 and 03 it is the middle one. In aother words, what is the logic?
# 4  
Old 01-31-2015
Ok any filename ? Are they in a file? How about just picking the first one?
Code:
awk -F- '!A[$1]++' file

Output:
Code:
sms_task_id_01-12345.csv
sms_task_id_02-12345.csv
sms_task_id_03-12345.csv

This User Gave Thanks to Scrutinizer For This Post:
# 5  
Old 01-31-2015
What is meaning of file here
Quote:
awk -F- '!A[$1]++' file
we are using here many files but you mention only word 'file' please explain it.
# 6  
Old 01-31-2015
"file" would be the name of the file that contains the "sms_task_id" file names that you specified. It is an assumption of what your input looks like, because that wasn't specified in the posts #1 and #3..

Last edited by Scrutinizer; 01-31-2015 at 06:15 AM..
# 7  
Old 01-31-2015
Hello aaditya321,

I will suggest you to go through forum's search option, this is very commonly asked question, if you feel the difficulty please check with man awk, if you feel you still need to understand it, we can help you but please do let us know what you have understood, so that it will help you and us to learn which is aim of this forum.

Thanks,
R. Singh
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