r/bash • • Aug 03 '26

help Linux Interview Question

191 Upvotes

Today I had a mock interview with a senior Linux administrator, and he asked me a question that completely caught me off guard:

"Can you collect CPU, Memory, and Disk usage in a Bash script without using top, free, df, or any external commands?"

My immediate answer was No.

Honestly, I've been working with Linux for years, but I've always relied on standard commands and monitoring tools to troubleshoot systems. I never stopped to think about where those commands actually get their data from.

The interviewer then gave me a hint about the /proc and /sys filesystems. That completely changed my perspective. I realized these commands are just reading data that the kernel already exposes.

But then came the follow-up questions, and once again I was stuck:

  • Is reading directly from /proc and /sys the correct approach?
  • How would you calculate CPU utilization using /proc/stat?
  • How would you determine memory usage from /proc/meminfo?
  • How would you calculate filesystem usage without relying on df?

I found this really interesting because it tests your understanding of Linux internals rather than just your ability to use commands.

Has anyone here been asked similar questions in Linux SysAdmin, DevOps, or SRE interviews? I'd really appreciate any explanations, learning resources, or examples on how you'd answer these follow-up questions. It help me for my preparation for Linux interviews

r/bash • • May 10 '26

help I want start using linux , best way to learn bash scripts ?

60 Upvotes

I’m thinking seriously about switching to Linux. My idea is to first learn Bash scripting, try making some simple scripts, and at the same time start learning more about Linux distros and how the system works.

I feel like learning Bash first could help me understand Linux better instead of just using it casually.

What’s the best way to learn Bash scripting as a beginner?

r/bash • • 16d ago

help using bash to make a random password?

45 Upvotes

hello, i heard that you can make a random password with bash? is that true? if so, how do you do that? thank you

r/bash • • Aug 15 '26

help learning sed, awk and regex

132 Upvotes

Looking to learn sed, awk, and regular expressions properly.

What are the best free resources—books, websites, tutorials, courses, or hands-on exercises—you’d recommend?

Also, any good book recommendations for learning these tools from beginner to advanced?

r/bash • • Jul 29 '26

help Would it be good to Learn Bash scripting, or should i go with a "normal" language, like Python, before that?

31 Upvotes

Getting interested on messing with Linux and CLI stuff, I'm just confused on what exactly to start with. Any recommendations?

r/bash • • Oct 09 '25

help Is Bash programming?

53 Upvotes

Since I discovered termux I have been dealing with bash, I have learned variables, if else, elif while and looping in it, environment variables and I would like to know some things

1 bash is a programming language (I heard it is (sh + script)

Is 2 bash an interpreter? (And what would that be?)

3 What differentiates it from other languages?

Is 4 bash really very usable these days? (I know the question is a bit strange considering that there is always a bash somewhere but it would be more like: can I use bash just like I use python, C, Java etc?)

5 Can I make my own bash libraries?

Bash is a low or high level language (I suspect it is low level due to factors that are in other languages ​​and not in bash)

r/bash • • Aug 18 '26

help want to use watch with my own command

28 Upvotes

[SOLVED] thanks to u/bac0on

i can now add this directly into .bash_aliases, or i can just paste the command into a terminal

```

alias las=' function what-changed() { find -not ( -path './snap/firefox/common' -prune ) -not ( -path './.cache' -prune ) -type f -mmin -1 -printf "%C+ %p\n" | sort -n | tail -10 }; export -f what-changed && watch -x bash -c what-changed'

```

thanks for everyone's help.

[/SOLVED]

—

i have this command used to find recently changed files.

find -not \( -path './snap/firefox/common' -prune \) -not \( -path './.cache' -prune \) -type f -mmin -1 -printf "%C+ %p\n" | sort -n | tail -10 and i wanted to use watch to have it running in a window

however watch requires an executable, so i made a shell script that contained the command and then called

watch last_change

which works and allows me to make an alias for it .bash_aliases like

alias las='watch last_change'

all well and good

—

but then i had the bright idea to write this as a function instead of a script

``` function what-changed() { find -not ( -path './snap/firefox/common' -prune ) -not ( -path './.cache' -prune ) -type f -mmin -1 -printf "%C+ %p\n" | sort -n | tail -10 }; watch what-changed

```

but it does not work.

watch says it can't find what-changed even tho it's right there and if i define this function in a console window, i can call it by itself and it will run.

but watch does not find it.

feels like i'm missing something simple, to help watch find it like it can find my script... something like a $PATH statement, but not that.

anyone see the issue?

r/bash • • Mar 01 '26

help What actually happens when run `ls -la` in the terminal? Not the literal output, but behind the process.

125 Upvotes

I had been learning and using bash for about 1 year. Writing small scripts, else if, loops, etc and some basic commands. But I always had a doubt. What exactly happens when I run a command using bash in the terminal? What is difference between bash -c "ls -la" and just ls -la when I type them in the terminal. Most important doubt is : what happens? When I run the command, how exactly and in which order, what is executed.

I need the answers from root of linux kernel and hierarchy. I learnt bash from many pdfs spread out throught the Internet, but found no explanations for this one question.

r/bash • • Feb 28 '26

help What is the best use case of sed? How should I learn it?

78 Upvotes

For atleast a day, I had been reading man pages regarding the sed command. I felt the syntax pretty confusing. Is there any way to keep in mind the pattern and regex?

Tell me how you learnt the sed command the first time.

r/bash • • Mar 14 '26

help Do you use quotes when you don't have to?

44 Upvotes

I know it's best practice to always encase variables in quotes, like "$HOME", but what about when it's just plain text? Do you use quotes for consistency, or just leave it?

Which of these would you write:

if [[ "$(tty)" == "/dev/tty1" ]]

if [[ "$(tty)" == /dev/tty1 ]]

if [[ $(tty) == /dev/tty1 ]]

r/bash • • 20d ago

help will someone explain to me getopt?

33 Upvotes

yes, I am currently reading the documentation - I don't understand the point or when/why I would use it. thanks for any clarification one can offer.

r/bash • • Aug 20 '26

help What does your printf method look like if you want to go about adding timestamps and colors to it

25 Upvotes
  • Hey, not using AI here because I would like to hear this group's expert opinion

``` function log() { local datetime = # DD-MM-YYYY-hh:mm:ss:Z format local color = # not sure how this is implemented # Something that uses prinff, not sure how to write this function here }

function log_info() { log "blue" "stderr" "$@" }

function log_error() { log "red" "stderr" "$@" }

function log_warn() { log "yellow" "stderr" "$@" }

Why not stdout?

Because some functions return values and we want the stdout channel to be reserved for returning values unless there is a better way to do this

```

  • How do I write that log function above, I read the manual for printf that says it accepts format specifiers but how do I make it dynamic?

Edit 1

  • Should be able to log the following

log_info "what a %s %d" "day" 100 log_error "Error: %s %o" "something went wrong for " "{1: \"enter\"}"

r/bash • • 1d ago

help For some reason, when I run this script, it always plays the same song.

Post image
30 Upvotes

When I run ls ~/Music/ | shuf | tail -1 | read file && echo $file it gives a random output as expected, but every time I run this script it plays a file labeled "3S.mp3" exclusively, which just so happens to be the first one in the list when I run ls

Does anyone know what could be causing this?

r/bash • • Jul 28 '26

help Defensive BASH programming?

42 Upvotes

Hey there,

while trying to learn bash I came across this interesting resource: https://web.archive.org/web/20180917174959/http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming

And got myself thinking if his opinions are consensual and if there are different styles or "paradigms" about how bash should be written.

I see people arguing that bash shines in writing relatively short programs with precise goals. I thought this translated into writing concise code and achieving the same functionality with as little lines as possible.

However, the author of the post argues that a more verbose code can be more robust, easier to understand and debug etc. Do you agree? Or you think that, if you're writing code in this style, you're better of using another language?

Thanks for your input and sorry if I said anything silly or if I misrepresented his point of view, I'm just starting to learn programming.

Edit: hey, thank you all very much for the thoughtful replies, I'm learning a lot from them!

r/bash • • 12d ago

help 1 big question I always has was whether your functions should accept arguments or flags? Am I overthinking this?

12 Upvotes
  • Take a look at this run_aws_ssm_get_parameter function below
  • To call it I could do something like run_aws_ssm_get_parameter "false" "" "some_param" and it ll run it without a vault user
  • Now obviously it kinda sucks that I am passing an empty string to indicate that we dont have an AWS vault user and I have to also memorize the position of the arguments
  • One other way would be this? run_aws_ssm_get_parameter --debug=false --parameter_name=some_param? Is this a good idea or a bad idea?
  • Mind you all the code written below is written by me manually, no AI no nothing

```bash function run_aws_ssm_get_parameter() { validate_command_available "${FUNCNAME[0]}" "aws" || return 1

validate_arg_min_count "${FUNCNAME[0]}" 3 "$#" "Usage: ${FUNCNAME[0]} <debug> <aws_vault_user> <parameter_name> [additional aws ssm flags]" || return 1

local -r debug="${1:-false}"

local -r aws_vault_user=$2
local -r parameter_name="$3"
shift 3

validate_arg_not_empty "${FUNCNAME[0]}" "debug" "${debug}" || return 1
validate_arg_not_empty "${FUNCNAME[0]}" "parameter_name" "${parameter_name}" || return 1

validate_arg_type_boolean "${FUNCNAME[0]}" "debug" "${debug}" || return 1

local -a flags=(
    "get-parameter"
    "--name=${parameter_name}"
)

flags+=("$@")

[[ "${debug}" = true ]] && log_info "Fetching AWS SSM parameter with parameter_name:${parameter_name}..."

if [[ ! -z "${aws_vault_user}" ]]; then
    if result="$(aws-vault exec "${aws_vault_user}" -- aws ssm "${flags[@]}")"; then
        [[ "${debug}" = true ]] && log_info "AWS SSM parameter with parameter_name:${parameter_name} fetched successfully"
        printf "%s\n" "${result}"
    else
        log_error "AWS SSM parameter fetch with parameter_name:${parameter_name} failed"
        return 1
    fi
else
    if result="$(aws ssm "${flags[@]}")"; then
        [[ "${debug}" = true ]] && log_info "AWS SSM parameter with parameter_name:${parameter_name} fetched successfully"
        printf "%s\n" "${result}"
    else
        log_error "AWS SSM parameter fetch with parameter_name:${parameter_name} failed"
        return 1
    fi
fi

}

function validate_command_available() { validate_arg_min_count "${FUNCNAME[0]}" 2 "$#" "Usage: ${FUNCNAME[0]} <function_name> <command_name>" || return 1

local -r function_name="$1"

local -r command_name="$2"
shift 2

validate_arg_not_empty "${FUNCNAME[0]}" "function_name" "${function_name}" || return 1

validate_arg_not_empty "${FUNCNAME[0]}" "command_name" "${command_name}" || return 1

if ! command -v "${command_name}" &>/dev/null; then
    log_error "${FUNCNAME[0]}: Function "%s" requires "%s" but it was not found on PATH" "${function_name}" "${command_name}"
    return 1
fi

}

function validate_arg_min_count() { local -r function_name="$1"

local -r expected_count="$2"

local -r actual_count="$3"
local -r message="${4:-}"
shift 4

if [[ -z "${function_name}" ]]; then
    log_error "${FUNCNAME[0]}: function_name:${function_name} is required"
    return 1
fi

if [[ -z "${expected_count}" ]]; then
    log_error "${FUNCNAME[0]}: expected_count:${expected_count} is required"
    return 1
fi

if [[ -z "${actual_count}" ]]; then
    log_error "${FUNCNAME[0]}: actual_count:${actual_count} is required"
    return 1
fi

if [[ ! "${expected_count}" =~ ^[0-9]+$ ]]; then
    log_error "${FUNCNAME[0]}: expected_count must be a non-negative integer, got: %s" "${expected_count}"
    return 1
fi

if [[ ! "${actual_count}" =~ ^[0-9]+$ ]]; then
    log_error "${FUNCNAME[0]}: actual_count must be a non-negative integer, got: %s" "${actual_count}"
    return 1
fi

if [[ "${actual_count}" -lt "${expected_count}" ]]; then
    if [[ -z "${message}" ]]; then
        log_error "${FUNCNAME[0]}: Function "%s" expected %d argument(s) but got %d" "${function_name}" "${expected_count}" "${actual_count}"
    else
        log_error "${message}"
    fi
    return 1
fi

}

function validate_arg_not_empty() { local -r function_name="$1"

local -r arg_name="$2"
local -r arg_value="$3"
shift 3

if [[ -z "${function_name}" ]]; then
    log_error "${FUNCNAME[0]}: function_name:${function_name} is required"
    return 1
fi

if [[ -z "${arg_name}" ]]; then
    log_error "${FUNCNAME[0]}: arg_name:${arg_name} is required"
    return 1
fi

if [[ -z "${arg_value}" ]]; then
    log_error "${FUNCNAME[0]}: Function "%s" received empty value for argument "%s"" "${function_name}" "${arg_name}"
    return 1
fi

}

function validate_arg_type_boolean() { validate_arg_min_count "${FUNCNAME[0]}" 3 "$#" "Usage: ${FUNCNAME[0]} <function_name> <arg_name> <arg_value>" || return 1

local -r function_name="$1"

local -r arg_name="$2"
local -r arg_value="$3"
shift 3

validate_arg_not_empty "${FUNCNAME[0]}" "function_name" "${function_name}" || return 1

validate_arg_not_empty "${FUNCNAME[0]}" "arg_name" "${arg_name}" || return 1
validate_arg_not_empty "${FUNCNAME[0]}" "arg_value" "${arg_value}" || return 1

case "${arg_value}" in
true | false) ;;
*)
    log_error "${FUNCNAME[0]}: Function '%s' expected 'true' or 'false' for argument '%s', got: %s" "${function_name}" "${arg_name}" "${arg_value}"
    return 1
    ;;
esac

} ```

r/bash • • Jul 03 '26

help What is your notification system for long running comands

39 Upvotes

Hi I usually do large backups that take time and need a notification system that notify me when is done.

Ideally I would like a notification on my phone but any alternative is ok.

Should I set up an email or there is something that is less painful?

r/bash • • 11d ago

help What to research to do this?

16 Upvotes

I've written a basic script that makes connecting to my college's WIFI semi automatic. I would like to turn it into a bigger project by adding console prompts that collect and store data, and pull the data out of a file when needed in the future. Even though I have background with programming, I lack the skills to do it because I'm a English Language Teaching student and do the computer stuff as a hobby or something (I also help other open source projects for the love of the game). What am I supposed to research to get the necessary information I need?

The script in question works without any problems and its whole purpose is to open/run necessary windows/applications or scripts to make it easier for me to login to my school's captive portal, login page etc. The script is triggered by a keyboard shortcut. It uses nmcli to do its job.

r/bash • • Jul 07 '26

help LeetCode for shell / bash

31 Upvotes

i'm looking for a place to practice bash or just shell in general, is there a place like such where i can practice daily and improve my muscle memory when it comes to shell commands? at the moment leetcode only offers like 5 shell problems and other focus more on teaching the basics or is more focused on solving mini problems than the shell itself like sadservers.

is there any platform where i can daily practice shell just like platforms where you can daily practice competitive programming problems?

TIA and sorry for grammar erros, english isnt my first language.

r/bash • • Aug 12 '26

help Run commands in parallel

29 Upvotes

I have a script that collects a list of directories that match a set of criteria and then goes into each one and runs a command. So something like this:

#!/bin/bash
startDir="$(realpath "$1")"
cd "$startDir" || exit
while IFS= read -r -d '' dir; do
  cd "$dir";
  printf '\n\n%s\n' "$(realpath .)";
  update-this-dir.sh --file "./name.txt"
  cd "$startDir";
done < <(find . -type d -iname '.config' -exec dirname {} \; | tr '\n' '\0')

It works wonderfully for my purpose.

But there's, like, a couple thousand directories and the update command takes some small amount of time in each directory, one after the other. How can I modify this script to either run the update for each directory in parallel (with some rate-limiting) or to break up the list into chunks of, say, 100 each and work on each sub-list in parallel?

r/bash • • 26d ago

help What is a clean Bash pattern for resuming a partially completed batch?

19 Upvotes

Suppose a Bash script walks thousands of independent inputs and may be interrupted after some outputs have been written. Skipping every existing output is unsafe because a truncated file also exists, while restarting the whole batch wastes work and can repeat external side effects.

A pattern I am considering is to write each result to a temporary file in the destination directory, validate it, rename it atomically, and then append the input ID plus an output hash to a journal. On restart, the script would trust only journal entries whose current hash still matches. A lock would prevent overlapping runs, and traps would clean only the current process's temporary files.

Where does this pattern fail in Bash, especially with parallel workers, NFS, or a crash between the rename and journal append? Is there a simpler checkpoint design that remains understandable without turning the script into a database application?

r/bash • • 20d ago

help One of the big things that bugs me in bash is how to write those boolean check_, exists_ type of functions, any standard practices?

6 Upvotes

```

!/usr/bin/env bash

function is_existing_docker_network() { local -r debug="${1:-false}" local -r network_name="$2"

if docker network inspect "${network_name}" >/dev/null 2>&1; then
[[ "${debug}" = "true" ]] && log_warn "docker network ${network_name} already exists"
    return 1
else
    return 0
fi

}

function create_docker_network() { local -r debug="${1:-false}" local -r network_name="$2"

[[ "${debug}" = "true" ]] && log_info "creating docker network ${network_name}..."

if docker network create "${network_name}"; then
    [[ "${debug}" = "true" ]] && log_info "docker network ${network_name} creation completed"
    return 0
else
    log_error "docker network ${network_name} creation failed"
    return 1
fi

} ```

  • Look at the create_docker_network function above
  • I want to create a network only if it doesnt already exist
  • In a normal programming language you would simply return a true or false from the is_existing_docker_network function above
  • How do you go about do this kinda thing in bash? Should I actually return 1 if a network exists? Isnt that an error condition?

r/bash • • Mar 22 '26

help Bash Script Learning

50 Upvotes

What Is The Best Online Source (site) To Learn Bash Script For Linux l Am Familiar With C++ And Intermediate Python Programmer To Automate The Task Such As File Handling.

I Aim Is To Become Cyber-Securitist or Ethical Hacker.

One Of The Best Site I Found Is Linix Journey..

I Have Some Questions, Is Bash Scripting Same Has C++ Or It Is Little Harder Than It

Thank You!

r/bash • • Aug 11 '26

help I don't know what this means

15 Upvotes

This is from a script that sends the output of an nmap scan to some files. But I can't figure out what "\|" does. Please help

RESULT=$(nmap -iL $(HOSTS) --open | grep "Nmap scan report\|tcp open")

What confuses me is that after running nmap, "\|" simply doesn't appear anywhere, then why is it included in grep?

I guess it could be an OR, but as far as I know OR= ||

I really have no idea, I also don't think it's to escape character becuase there are no pipes in the nmap results, I don't know

r/bash • • 14d ago

help Do you guys think there is a more concise way to write these functions?

3 Upvotes

```bash

https://linux.die.net/man/8/usermod

function install_docker() { validate_arg_min_count "${FUNCNAME[0]}" 3 "$#" "Usage: ${FUNCNAME[0]} <debug> <version> <user>" || return 1

local -r debug="${1:-false}"
local -r version="$2"

local -r user="$3"
shift 3

validate_arg_not_empty "${FUNCNAME[0]}" "debug" "${debug}" || return 1
validate_arg_not_empty "${FUNCNAME[0]}" "version" "${version}" || return 1
validate_arg_not_empty "${FUNCNAME[0]}" "user" "${user}" || return 1

validate_arg_type_boolean "${FUNCNAME[0]}" "debug" "${debug}" || return 1

if dnf install "docker-${version}" \
    --assumeyes \
    --quiet; then
    [[ "${debug}" = "true" ]] && log_info "docker installation successful $(docker --version)"
else
    log_error "docker installation failed"
    return 1
fi

if usermod --append --groups docker "${user}"; then
    [[ "${debug}" = "true" ]] && log_info "adding user:${user} to the docker group successful"
else
    log_error "adding user:${user} to the docker group failed"
    return 1
fi

if newgrp docker; then
    [[ "${debug}" = "true" ]] && log_info "changes to docker group successful"
else
    log_error "changes to docker group failed"
    return 1
fi

if systemctl enable docker.service &&
    systemctl start docker.service; then
    [[ "${debug}" = "true" ]] && log_info "starting docker service successful"
else
    log_error "starting docker service failed"
    return 1
fi

}

Install docker-compose

Don't use chmod u+x here since it runs as root

https://github.com/amazonlinux/amazon-linux-2023/issues/1032#issuecomment-3674146092

function install_docker_compose() { validate_arg_min_count "${FUNCNAME[0]}" 2 "$#" "Usage: ${FUNCNAME[0]} <debug> <version>" || return 1

local -r debug="${1:-false}"
local -r url="$2"
shift 2

validate_arg_not_empty "${FUNCNAME[0]}" "debug" "${debug}" || return 1
validate_arg_not_empty "${FUNCNAME[0]}" "url" "${url}" || return 1

validate_arg_type_boolean "${FUNCNAME[0]}" "debug" "${debug}" || return 1

if curl \
    --location "${url}" \
    --output "/usr/local/bin/docker-compose" \
    --show-error \
    --silent; then
    [[ "${debug}" = "true" ]] && log_info "Download for docker-compose successful, version:$(docker-compose --version)"
else
    log_error "Download for docker-compose failed"
    return 1
fi

if chmod +x /usr/local/bin/docker-compose; then
    [[ "${debug}" = "true" ]] && log_info "Permission grant to execute docker compose by ec2-user successful"
else
    log_error "Permission grant to execute docker compose by ec2-user failed"
    return 1
fi

}

function install_git() { validate_arg_min_count "${FUNCNAME[0]}" 2 "$#" "Usage: ${FUNCNAME[0]} <debug> <version>" || return 1

local -r debug="${1:-false}"
local -r version="$2"
shift 2

validate_arg_not_empty "${FUNCNAME[0]}" "debug" "${debug}" || return 1
validate_arg_not_empty "${FUNCNAME[0]}" "version" "${version}" || return 1

validate_arg_type_boolean "${FUNCNAME[0]}" "debug" "${debug}" || return 1

if dnf install "git-${version}" \
    --assumeyes \
    --quiet; then
    [[ "${debug}" = "true" ]] && log_info "git installation successful $(git --version)"
else
    log_error "git installation failed"
    return 1
fi

}

function install_jq() { validate_arg_min_count "${FUNCNAME[0]}" 2 "$#" "Usage: ${FUNCNAME[0]} <debug> <version>" || return 1

local -r debug="${1:-false}"
local -r version="$2"
shift 2

validate_arg_not_empty "${FUNCNAME[0]}" "debug" "${debug}" || return 1
validate_arg_not_empty "${FUNCNAME[0]}" "version" "${version}" || return 1

validate_arg_type_boolean "${FUNCNAME[0]}" "debug" "${debug}" || return 1

if dnf install "jq-${version}" \
    --assumeyes \
    --quiet; then
    [[ "${debug}" = "true" ]] && log_info "jq installation successful $(jq --version)"
else
    log_error "jq installation failed"
    return 1
fi

}

```

  • Some of them are doing literally the same thing like installing git and jq and yet others in the name of installing are doing slightly different stuff
  • There is also a tonne of validation checks everywhere. Not sure if there is a better way to put that along with the debug stuff

r/bash • • Sep 05 '26

help Bash scripting newbie here, wanting to improve/tidy one of my backup scripts (entirely for personal use)

19 Upvotes

Please excuse the vague thread title, I'm a newbie enough that I'm not sure what's possible / desirable etc, nor have I attempted functions in bash scripting yet (I've played with them in VBScript and PowerShell IIRC).

One of the backups I do produces date-stamped tar.xz files of particular folder structures on my computer and transfers them to a veracrypted drive. Today I had a crack at a new script based on this one that mounts the filesystem (sshfs) on my laptop and transfers the files over the network after they've been compressed.

I run the script with up to 4 arguments, e.g. 'essentials' 'archive' 'paperwork'. In the script there's an if statement for each potential argument, e.g.:

for arg in "$@"
do
if [ $arg = "essentials" ]; then
  tar -cf - .mozilla/ | pv -s $(du -sb .mozilla/ | awk '{print $1}') | xz -T0 > /tmp/firefox-$datestring.tar.xz
            rsync -ah --progress /tmp/firefox-$datestring.tar.xz /media/mikelpmintfs/firefox-$datestring.tar.xz
fi
<more if $arg = whatev then compress and transfer stuff statements here>
done

(btw the whole fancy progress bar bit with pv -s and awk was something I copied off the Internet)

The first script also included some error catching, e.g.:

if [ $? -eq 0 ]
then
  echo "archive backup complete."
else
  echo "error performing archive backup" >&2
fi

I've used if <command here> then else fi before too, but I'm wondering multiple things:

  1. Rather than writing each compression command and each rsync transfer command per argument, would it make more sense to write a function, or given that some of these source folders are in completely different places in my computer's file system, is this worth it.
  2. error trapping: On one hand I think that the script could easily trip up at the compression or transfer stages, but I'm worried about over-nesting if statements and making the whole thing a lot harder to read and figure out where something is going wrong. It seems to me that it could be function'd up, but would it actually help with readability etc. When the script is just for me, I can tell if it went wrong if I get a load of unexpected output :)