# sort passwd by 3rd field separated by ':'
oyj@oyjmint ~ $ cat /etc/passwd | sort -t : -k 3n
# To find info detail on sort command.
oyj@oyjmint ~/rp $ info coreutils 'sort invocation' > sortm
#!/usr/bin/env bash
#
# This script is for copying file that is >= 100000 bytes to destination directory # from current directory's directories.
#
DES_DIR="/data/des/"
CUR_DIR=$(pwd)
for i in $(ls)
do
cd $i
for j in $(ls -l | awk -F ' ' '{if (($5 >= 100000)) print $9}')
do
cp -fv $j $DES_DIR
done
cd $CUR_DIR
done
###############################################
#!/usr/bin/env bash
# awk if example.
cat /etc/passwd | awk -F: '{if (($3 >= 1000)) print $0 }' | sort -k3 -t":"
###############################################
################################################
# I want to delete(rm *.png) all png file.
# There are 217941 files.
# Argument list too long ####
#########################
oyjmint images # ls -f *.png | wc -l
bash: /bin/ls: Argument list too long
0
oyjmint images # rm -f *.png
bash: /bin/rm: Argument list too long
# -f option do trick well.
oyjmint images # ls -f | wc -l
217941
# So below command did the trick.
oyjmint images # for i in $(ls -f)
> do
> if [[ ! -d $i ]]
> then
> rm -fv $i
> fi
> done
^^;
No comments:
Post a Comment