Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 4th, 2011, 08:06 AM
mikeatvillage's Avatar
mikeatvillage mikeatvillage is offline
Learning MySQL, PHP & CSS
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Location: Powys/Shrops border (UK)
Posts: 266 mikeatvillage User rank is Sergeant Major (2000 - 5000 Reputation Level)mikeatvillage User rank is Sergeant Major (2000 - 5000 Reputation Level)mikeatvillage User rank is Sergeant Major (2000 - 5000 Reputation Level)mikeatvillage User rank is Sergeant Major (2000 - 5000 Reputation Level)mikeatvillage User rank is Sergeant Major (2000 - 5000 Reputation Level)mikeatvillage User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 16 h 43 m 15 sec
Reputation Power: 46
Send a message via Yahoo to mikeatvillage
Help with awk (I think!) SOLVED

Hi again. I have this code in my shell script but would like to get rid of the rather untidy "if" statement ... I _think_ 'awk' is what I need to be able to read from a plain text file which lists directories NOT to process. Basically doing "if $dirname is not in the text file, then ..." but I can't figure it out or find an example I could hack. Any suggestions are much appreciated.

Code:
cd /home
for dirname in `find -maxdepth 1 -mindepth 1 -type d | sort` ;
do
if [ $dirname != "./tech_transfer" -a $dirname != "./transfer" -a $dirname != "./lost+found" ] ; then
(rest of script...)
fi
done


SOLVED!

No worries, I found the solution was to use grep, not awk!


Code:
if ! grep -q $(basename $dirname) /usr/sbin/dirsize.txt ; then
__________________
It said 'Insert disk #2', but only one will fit.

Last edited by mikeatvillage : May 5th, 2011 at 05:16 AM. Reason: SOLVED

Reply With Quote
  #2  
Old May 5th, 2011, 06:25 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,111 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 7 h 43 m 38 sec
Reputation Power: 1485
Nice bit of lateral thinking!
Comments on this post
mikeatvillage agrees: Thanks Simon.
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Help with awk (I think!)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap