scripts

My personal collection of scripts
git clone git://src.gearsix.net/scriptsscripts.zip
Log | Files | Refs | Atom | README | LICENSE

catrm.sh (raw) (527B)


   1 #!/usr/bin/env bash
   2 # cat & remove
   3 # description: cat $@ and prompt to rm
   4 
   5 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
   6 	echo "Usage: 'catrm FILEPATHS...'"
   7 	echo ""
   8 	echo "prompt to remove listed files, with an option to (c)at them"
   9 	exit
  10 fi
  11 
  12 ync=
  13 for f in $@; do
  14 	unset ync
  15 	while [ ! $ync ]; do
  16 		read -p "remove '$(readlink -f $f)' [y/n/c]? " -n 1 ync
  17 		echo ""
  18 		if   [ "$ync" == "y" ]; then rm $f
  19 		elif [ "$ync" == "c" ]; then cat $f; unset ync
  20 		elif [ "$ync" == "n" ]; then continue;
  21 		else unset ync; fi
  22 	done
  23 done