LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-14-2012, 09:55 AM   #1
NickPats
Member
 
Registered: Oct 2012
Posts: 43

Rep: Reputation: Disabled
how to join this 2 script together


for dir in $1; do
echo $dir: $(ls "$dir" | wc -l)
done

awk '{for (i=1;i<=NF;i++){printf $i };printf "\n"}' < $2 | sort -n | tail -n1
 
Old 10-14-2012, 11:08 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
How are they related? I see no natural join between the 2 snippets.

Also, please use [code][/code] tags when displaying code.
 
Old 10-14-2012, 11:12 AM   #3
NickPats
Member
 
Registered: Oct 2012
Posts: 43

Original Poster
Rep: Reputation: Disabled
It first prints out the directory name and the total files that directory has.
like directory 1 has 25 files. it will print 1 : 25. i wanna use that output and find the directory with max files in it.

Last edited by NickPats; 10-14-2012 at 11:50 AM.
 
Old 10-14-2012, 11:59 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
So what has that got to do with the awk script? Also, it would appear this is a copy of a previous question you asked on how to find this information. Any reason why you have asked the same question again?
 
Old 10-14-2012, 01:02 PM   #5
NickPats
Member
 
Registered: Oct 2012
Posts: 43

Original Poster
Rep: Reputation: Disabled
I thought this would be easy. Sorry about that.
 
Old 10-14-2012, 11:12 PM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
It is not so much that it is difficult, but more that it is very unclear what you are trying to achieve?

I mean to combine them I could have simply said:
Code:
for dir in $1; do
echo $dir: $(ls "$dir" | wc -l)
awk '{for (i=1;i<=NF;i++){printf $i };printf "\n"}' < $2 | sort -n | tail -n1
done
But I somehow doubt this is what you are after.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script to join similar lines rei125 Programming 5 06-29-2012 04:25 AM
How would I write a script that would use join across all files in a directory? pinecone Programming 12 08-20-2010 10:48 AM
join files using shell script sailu_mvn Linux - Software 5 07-28-2006 02:13 AM
[Script] Join Fedora Core2 in Windows 2003 Domain L1nuxbug Linux - Networking 0 11-09-2004 07:26 PM
Bash script. How to join two IF in one? rytrom Linux - Newbie 1 07-19-2003 11:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration