simplfy


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

Code:
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
# 2  
Old 10-28-2008
Cool little script. It can be greatly simplified with ksh/bash/zsh. But I might also be slightly changing the behavior here.
Code:
level=`runlevel`
ls /etc/init.d/rc${level}.d/ | while read FILE
do
  FILENAME=${FILE##*/}
  if [ "${FILENAME#S}" != "$FILENAME" ]
  then
     tput smso
     echo -n $FILENAME
     tput rmso
  elif [ "${FILENAME#K}" != "$FILENAME" ]
     echo -n $FILENAME
  fi
done

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

I feel that i can Simplfy this but i am not fully sure how vars1=$(cat vartext | cut -d" " -f9) for word in $vars1 do var2=$(dirname $word) if ]; then ls -l $word ... (9 Replies)
Discussion started by: jafa401
9 Replies
Login or Register to Ask a Question