What's UNIX Expert's suggestion for this thread ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What's UNIX Expert's suggestion for this thread ?
# 1  
Old 03-18-2013
What's UNIX Expert's suggestion for this thread ?

Assume that 100 file's of type .txt are saved in directory
in which,
Code:
40 .txt files having ID 225 in column x
10 .txt files having ID 220 in column x
30 .txt files having ID 115 in column x
and remaining 20 .txt file's having UNIQUE ID say 226,227,228,229,230....

first I want to read only files with UNIQUE ID
like this
Code:
for file  in *.txt of UNIQUE ID; do
go_function_abc;
done

after this I want to read file's having ID 225
Code:
for file in *.txt of ID 225; do
execute_this_function_only_once; (this has to be executed only once I mean when $file==1,not 40 times)
go_to_function_xyz;(this has to be executed 1 to 39 times, that is filecount<no of files)
go_to_last_function(execute this function when filecount==No of files, thats 40==40)

Code:
then file's with ID 220,115...

Here for me, no problem in running file's with UNIQUE ID, if many file's are having same ID, then this is the only solution left to me

I hope UNIX Expert's will have solution for this.

Last edited by Akshay Hegde; 03-18-2013 at 01:15 AM..
# 2  
Old 03-18-2013
Sounds like an interesting problem.

But it might help to have some sample input. It would give a better idea what you mean by "column x".

And maybe a more descriptive title than "unix expert's suggestion" might be a good idea. That would be up to a moderator.
# 3  
Old 03-18-2013
Column X is containing ID, to indicate it is same for all files I mentioned X it's column 14
# 4  
Old 03-18-2013
Not clear. Is the column in the file name or in the file itself?

And, function_abc is the same all over, or does it change with the file in use?

Meanwhile you should know that it helps tremendously to post sensible sample data.
# 5  
Old 03-18-2013
Dear Sir, column is in file and function abc is only for file with unique ID

and for file's with same ID, there are 3 function,
1. 1st function should be executed only once that is at starting(don't repeat)
2. 2nd function should be executed till filecount <no of files(repeat)
3. 3rd function should be executed when filecount==no of files(don't repeat)
# 6  
Old 03-18-2013
Here's your (bash!) solution:
Code:
for file in *.txt; do read <"$file"; Ar=( "$REPLY" ); echo mv "$file" "$file.${Ar[1]}mod"; done

execute_this_function_only_once;  
for file in *.225mod; do go_to_function_xyz; mv "$file" "${file%.*}"; done
go_to_last_function

... same for 220, 115, ...

for file in *mod; do go_to_function_abc; mv "$file" "${file%.*}"; done

This User Gave Thanks to RudiC For This Post:
# 7  
Old 03-18-2013
Thank you , you mean manually we need to enter for *.225 .....;done
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. What is on Your Mind?

Any Google SEO Expert to Help UNIX.COM?

I checked (again) and it seems like we lost 70% of our Google indexed links starting in March 2018. So far, I do not know what caused this drop: https://www.unix.com/members/1-albums215-picture904.png As mentioned, I have done a lot of checking, and we did not make any changes in March of... (2 Replies)
Discussion started by: Neo
2 Replies

2. Cybersecurity

Looking for suggestion on authentication method for UNIX/Windows

Hello, We have mid level infrastructure of all on-premises servers. All windows servers are getting authenticated by Microsoft Active Directory Services, half Unix (Solaris+Linux) servers are getting authentication by NIS and other half by LDAP. We have plans to migrate from NIS to LDAP, so... (2 Replies)
Discussion started by: solaris_1977
2 Replies

3. Post Here to Contact Site Administrators and Moderators

Didn't find a suggestion thread

An 'addition' to the "Homework & Classes" requirements.. As i am someone without paper, i just figured i got tempred reading such a question. To avoid such 'feelings' in future, i'd be thankfull if the 'kind & definition of the course' would be required too. As in (i dont know about proper... (2 Replies)
Discussion started by: sea
2 Replies

4. UNIX for Dummies Questions & Answers

Need a suggestion on UNIX Books

Hi All, Request you to suggest any other book as of year 2013. The below thread is of year 2000 and I have not found the books mentioned in the link below. Which Unix Certification is the most needed these days? Or please share any updated thread is there on this. Thanks and regards,... (7 Replies)
Discussion started by: saps19
7 Replies

5. UNIX for Advanced & Expert Users

Suggestion Required for UNIX career

Hi, I am having experience on Perl and C# and worked as Windows Sytem Admin and now iam planning to become a UNIX developer. I am having knowledge on basic UNIX.. can any one suggest me any good material for c/c++ UNIX programming. on what all things a UNIX Programmer needs to... (1 Reply)
Discussion started by: chandrareddy1
1 Replies

6. Post Here to Contact Site Administrators and Moderators

Re: Suggestion to ease navigation .... thread

This post should be an edit of the post I just made to start the "Suggestion to ease navigation ..." thread, but my original post is not visible to edit, since it's waiting for moderator approval ... Additional text I wanted to add to my original post: The title of the The UNIX and Linux... (2 Replies)
Discussion started by: usnay12345
2 Replies

7. UNIX for Dummies Questions & Answers

Suggestion: Alternative OS for Windows - Totally Clueless on Unix/Linux OS

Can anyone tell me a good alternative to Windows? OS that can connect to a Windows domain and use for everyday (can use with Oracle). Easy to learn. (4 Replies)
Discussion started by: genesisX
4 Replies

8. Post Here to Contact Site Administrators and Moderators

Suggestion for unix.com

I am relatively new here ...but I had a suggestion. The first time I visited this site I tried to go to unix.com and it did not go anywhere I then said ok let try www.unix.com. I think that it would be a good pratice to change the zone file file so that when you go to unix.com it comes here as... (5 Replies)
Discussion started by: gennaro
5 Replies
Login or Register to Ask a Question