User Tools

Site Tools


zsh_notes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
zsh_notes [2023/01/03 21:15] – [Change the default shell] rajuzsh_notes [2023/01/26 21:27] (current) raju
Line 1: Line 1:
 +===== Sample scripts =====
 +
 +==== backup a directory ====
 +The idea here is to cd into a given directory and then backup a directory in it. The path names are hard coded to make things simple.
 +<code>
 +#! /usr/bin/env zsh
 +set -e
 +topdir=/home/rajulocal/notes
 +bdir=projects
 +
 +cd ${topdir}
 +
 +asof=`date +'%Y%m%d_%H%M%S'`
 +ofile=${bdir}_${asof}.txz
 +tar cJf ${ofile} ${bdir}
 +if [ $? -eq 0 ]; then
 +    printf "backup stored in: ${topdir}/$ofile\n";
 +fi
 +</code>
 +
 +Sample run:
 +<code>
 +% ~/bin/bkup_notes.sh
 +backup stored in: /home/rajulocal/notes/projects_20160103_224746.txz
 +</code>
 +
 ===== To be sorted ===== ===== To be sorted =====
  
zsh_notes.1672780552.txt.gz · Last modified: 2023/01/03 21:15 by raju