Skip to content
Snippets Groups Projects
Commit d9aece92 authored by Roman Inflianskas's avatar Roman Inflianskas Committed by Bruno Pinto
Browse files

bak plugin: add unbak function (inverse to mvbak)

parent 9f3a151a
Branches
No related merge requests found
# Function to move files and directories (a.txt.20140608_195859.bak move to a.txt)
# (c) Roman Inflianskas (rominf) <infroma@gmail.com>, 2014
function unbak
set re_bak '(.*)\.[0-9]{8,8}_[0-9]{6,6}\.bak'
set file $argv[1]
set normalized (echo "$file" | sed -E "s/$re_bak/\1/g")
function is_bak
echo "$file" | perl -ne "print if /$re_bak/" > /dev/null
end
if test ! -e $file
echo "File \"$file\" not exists! Cannot unbak \"$file\"."
else if not is_bak $file
echo "File \"$file\" don't meet bak files convention! Cannot unbak \"$file\"."
else if test -e $normalized
echo "File \"$normalized\" exists! Cannot unbak \"$file\"."
else
mv $file $normalized
end
end
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment