this is straight out of the bash scripting howto. I didnt write this.Code:#!/bin/bash if [ -z "$1" ]; then echo usage: $0 directory exit fi SRCD=$1 TGTD="/var/backups/" OF=home-$(date +%Y%m%d).tgz tar -cZf $TGTD$OF $SRCD
How could I make a script that functioned like this:
when you run the script like this
script.sh "filename"
the script would run
tar xvfj "filename"
this is straight out of the bash scripting howto. I didnt write this.Code:#!/bin/bash if [ -z "$1" ]; then echo usage: $0 directory exit fi SRCD=$1 TGTD="/var/backups/" OF=home-$(date +%Y%m%d).tgz tar -cZf $TGTD$OF $SRCD
Or you could just make it a regular script, run it like ./tarscript and use something liek this:
#!/bin/bash
echo "What file would you like to tar up?"
read filename
tar zxvf $filename
echo "all done"
But i was readin your post again and i wasnt sure if you wanted to tar something up or have it untar.... To untar you could set alais in your bash_profile tar = tar -zxvf
Yeah it was to untar them, see I'm trying to make my own distro, at least a rough idea of it. So for a somewhat crude package managment system, i needed it. All my packages are just .tar.bz2 files, I have a way of uninstalling packages already, and I needed that for installing them. That is unitill I take the time later to figure out how to make a more elaborate system.
OK I have another bash scripting questions,
right now whenever you add a package it writes the package name into a text file, I need to know how to remove that packages name from teh database when you remove it.
This is one way. Assuming the package we want to remove is contained in shell variable "$rmpkg" and the name of the package database file is "installed-pkgs":
With a bit of refinement (eg check the new file is created ok, then move it back as "installed.pkgs"Code:grep -v $rmpkg installed-pkgs > installed-pkgs.newit would be workable.
Not that I am a guru in any of this, but a future modification may be to make a db instead of a text file for your software list. This could enable you to create a key to search for, which would speed your searches for a particular package considerably. Just a thought....
Bookmarks