I'm trying to create an alias for a command that renames a folder and then tar-zips it:
alias txz='of=$1; nf=$of$(date -I); mv $of $nf; tar cJvf $nf.txz $nf --remove-files'
call with
txz test_folder
I get errors
mv: missing destination file operand after ‘2014-05-14’
Try 'mv --help' for more information.
tar: 2014-05-14: Cannot stat: No such file or directory
test_folder/
test_folder/1
test_folder/2
tar: Exiting with failure status due to previous errors
Because of multiple commands. If there is only one command (no ;
), $1
works.
Is there any way to resolve it?
ps: here is the command to create the test folder:
mkdir test_folder; touch test_folder/1 test_folder/2