You are not logged in.
Pages: 1

I would like to have a bash function that lets me create tar.xz archives. I have the following in my bash now:
mktar() { tar cf  "${1%%/}.tar"     "${1%%/}/"; }
mktgz() { tar czf "${1%%/}.tar.gz"  "${1%%/}/"; }
mktbz() { tar cjf "${1%%/}.tar.bz2" "${1%%/}/"; }Any advice would be appreciated.
Last edited by orphius1970 (2010-09-06 11:10:39)
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline

cJf
capital j
Give what you have. To someone, it may be better than you dare to think.
Offline
archive () {
  FILE=$1
  shift
  case $FILE in
    *.tar.bz2) tar -cjf $FILE $* ;;
    *.tar.gz) tar -czf $FILE $* ;;
    *.tar.lzma) tar --lzma -cf $FILE $* ;;
    *.tar.xz) tar --xz -cf $FILE $* ;;
    *.tgz) tar -czf $FILE $* ;;
    *.zip) zip $FILE $* ;;
    *.rar) rar $FILE $* ;;
  esac
}Offline

wintervenom, how do I use that function, an example please
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline

orphius1970 should learn some shell scripting. 
$FILE is obviously the archive name and is $1 the first argument.
$* would be the rest of the arguments (only so after the shift command.
So, archive archive_name list of files to be archived.
Example: archive stuff.tar.gz stuff/
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline

thank you. now I understand.
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
Pages: 1