📄 l-trash.sh
字号:
#!/bin/sh# l-trash.sh# coded by Enrico "lupsyn" Del Zotto# http://lupsyn.cjb.net# for lab of o.s. 2002/2004clearcestino=~/.cestinoif (! test -d $cestino) then mkdir ~/.cestino echo "Create the trash dir in ~/.cestino" ls -la $cestinofiif test $# -eq 0 then name=$(echo $0 | tr -d "./") echo "[*]----------------------$name----------------------[*]" echo " * Usage : $name [Options] [Filenames] * " echo " * Flags option help :-l List of the trash * " echo " * -p Empty the trash * " echo " * -r <filename> <path_to_restore> Restore a file * " echo "[*]---------------------------------------------------[*]"exit 0fiif test $1 = '-l' then ls -la $cestinoexit 0fiif test $1 = '-p' then rm -rf $cestino mkdir $cestinoexit 0fiif test $1 = '-r' then if test $# -ne 3 then echo "[*] Restore flag sintax : <File to restore> <Path>" else if test -f $cestino/$2 then if test -f $2 then echo "[*] There is another file in the PATH $3 whit the name of your file to restore [*]" echo "[*] What we do ? [*]" while echo "[1] Overwrite_the_file_in_$2 [2] Change_the_name_to_the_file_to_restore [3] Abort_operation" read risp do case "$risp" in "1") mv $cestino/$2 $3 break ;; "2") echo "[*] Change the name to the file to restore:" read new_name mv $cestino/$2 $3/$new_name break ;; "3") break ;; esac done else mv $cestino/$2 $3/ fi else echo "[*] The file $2 in $cestino doesn't exists see: [*]" ls -la $cestino exit 0 fi fiexit 0fiif test $1='-f'theni=1tot=$#until (! test $i -le $tot ) #Ciclo per prendere i file e metterli nel cestinodoif (test -f $1)thenif(test -f $cestino/$1) then echo "[*] There is another file in trash with the name $1 int the trash[*]" echo "[*] What we do? [*]" while echo "[1] Overwrite [2] Trash_it_Whit_another_name [3] Cancel" read risp do case "$risp" in "1") mv $1 $cestino/$1 break ;; "2") echo "[*] Insert new name for the file :" read new_name mv $1 $cestino/$new_name break ;; "3") break ;; esac doneelse mv $1 $cestinofielseecho "[*] The file $1 you want to put in the trash doesn't exists see: [*]"ls -lafishifti=$(($i+1)) doneexit 0fi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -