LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 10: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, 12:08 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,424

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
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, 12:12 PM   #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 12:50 PM.
 
Old 10-14-2012, 12:59 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,424

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
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, 02: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-15-2012, 12:12 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,424

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 05:25 AM
How would I write a script that would use join across all files in a directory? pinecone Programming 12 08-20-2010 11:48 AM
join files using shell script sailu_mvn Linux - Software 5 07-28-2006 03:13 AM
[Script] Join Fedora Core2 in Windows 2003 Domain L1nuxbug Linux - Networking 0 11-09-2004 08:26 PM
Bash script. How to join two IF in one? rytrom Linux - Newbie 1 07-19-2003 12:14 PM


All times are GMT -5. The time now is 05:05 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration