Simplfy


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Simplfy
# 1  
Old 10-31-2008
Simplfy

I feel that i can Simplfy this but i am not fully sure how
Code:
 vars1=$(cat vartext | cut -d" " -f9)
                for word in $vars1
                do
                        var2=$(dirname $word)
                        if [[ -w $var2 && -w $word ]]; then
                                ls -l $word
                        else
#rest of the code

# 2  
Old 10-31-2008
Tools

Code:
 vars1=$(cat vartext | cut -d" " -f9)
                for word in $vars1

replace with
Code:
for word in `cut -d" " -f9 vartext`

Without seeing the input file (vartext), or knowing more of what you are attempting to do, I do not see much more to adjust.
# 3  
Old 10-31-2008
the vartext has results from a find command
# 4  
Old 10-31-2008
Code:
var1=$(find ./ -size +10k 2> /dev/null)  
                if [[ $var1 = ""  ]]
					then                     
			# rest of the of script

Ok i want to cut back on making vars
i trying to figure out how check the out put without a var
# 5  
Old 10-31-2008
Hammer & Screwdriver What about this?

Code:
> if [ `find ./ -size +20k | wc -l` -gt 0 ]; then echo "found files"; fi
found files

Instead of echo, you could do whatever you need to program
# 6  
Old 10-31-2008
so instead of putting all errors to /dev/null you
instead counted the output and if its greater then 0

see i got an else statement if the output is not 0
so counting it wouldnt work right?
# 7  
Old 10-31-2008
Code:
if [ `find ./ -size +20k | wc -l` -eq 0 ]; then echo "found files";else

So i didnt really need to pipe errors to dev/null

if can just count it then
so i would have to use eq operator?
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help to Simplfy

while ]; do echo "ID format - 000-000-000" read -p "Enter Name: " usrnme read -p "Enter ID: " id if echo $usrnme | grep "^" > /dev/null then vrfy="true" else until ; do ... (2 Replies)
Discussion started by: jafa401
2 Replies

2. Shell Programming and Scripting

simplfy

ls /etc/init.d/rc4.d/ | while read FILE do tput smso echo -n `expr "$FILE" : '\(S.*$\)'` tput rmso echo `expr "$FILE" : '\(K.*$\)'` done this is part of my code i feel that i can simplify this even more but not sure (1 Reply)
Discussion started by: jafa401
1 Replies
Login or Register to Ask a Question