Last active
October 27, 2015 13:34
-
-
Save walbon/9f1facb1019cfc0c9635 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#alias .CHOOSE='if [[ $FILES ]] ; then ~/.choosing.sh ${FILES} | while read line; do for item in $line; do echo $item; done | xargs ${COM} ; done ; fi; FILES=""; COM=""' | |
# Usage : | |
# FILES=$(ls *.txt); COM="egrep -i walbon"; .CHOOSE | |
# | |
pkglist="" | |
pkglist2="" | |
n=1 | |
echo $* | |
for pkg in $* | |
do | |
pkglist="$pkglist $n $pkg off" | |
pkglist2="$pkglist2;-$n;$pkg|" | |
n=$[n+1] | |
done | |
choices=`/usr/bin/dialog --stdout --checklist 'Choose item:' 80 40 $n $pkglist` | |
stdouted="" | |
if [ $? -eq 0 ] | |
then | |
for choice in $choices | |
do | |
for item in $(echo $pkglist2 | sed -e "s/|/ /g") | |
do | |
stdouted="$stdouted `echo $item | egrep ";-$choice;" | cut -d';' -f3-`" | |
done | |
done | |
else | |
exit 1 | |
fi | |
echo $stdouted | |
export stdouted="$stdouted" | |
#$ ./.choosing.sh onca macaco baleia girafa veado |while read line; do for item in $line; do echo $item; done | xargs ls ; done | |
#COM="ls -hs";FILES="$(ls)";./.choosing.sh ${FILES} |while read line; do for item in $line; do echo $item; done | xargs ${COM} ; done | |
#alias .CHOOSING="read FILES; read COM; if [[ \$FILES ]] ; then ~/.choosing.sh \${FILES} | while read line; do for item in \$line; do echo \$item; done | xargs \${COM} ; done ; fi;" | |
#alias .CHOOSING="read FILES; read COM; if [[ \$FILES ]] ; then ~/.choosing.sh \${FILES} | while read line; do for item in \$line; do echo \$item; done | xargs \${COM} ; done ; fi;" | |
#alias .CHOOSE='if [[ $FILES ]] ; then ~/.choosing.sh ${FILES} | while read line; do for item in $line; do echo $item; done | xargs ${COM} ; done ; else echo; echo "CHOSE usage: You need define the environment variables, FILES and COM."; echo " - FILES: Itens to be choose."; echo " - COM: The command that will execute." ; fi; FILES=""; COM=""' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
alias .CHOOSING="read FILES; read COM; if [[$FILES ]] ; then ~/.choosing.sh $ {FILES} | while read line; do for item in $line; do echo $item; done | xargs $ {COM} ; done ; fi;"$FILES ]] ; then ~/.choosing.sh $ {FILES} | while read line; do for item in $line; do echo $item; done | xargs $ {COM} ; done ; else echo; echo "CHOSE usage: You need define the environment variables, FILES and COM."; echo " - FILES: Itens to be choose."; echo " - COM: The command that will execute." ; fi; FILES=""; COM=""'
alias .CHOOSE='if [[