Forgotten your password?

Forum Index > Bash/Shell > Easy, introductory scripts
Author Message
Simple backup script:

1
2
#!/bin/bash
tar -cZf /var/my-backup.tgz /home/me/


In this script, the user files in the library of a home we bind it together into an only bald file.

From the redirection:
There are three file descriptors: stdin, stdout and stderr (std=standard).
Fundamentally the successors can be covered:
1. stdout into a file his management
2. stderr into a file his management
3. stdout into stderr his management
4. stderr into stdout his management
5. stderr and stdout into a file his management
6. stderr and stdout into stdout management
7. stderr and stdout into stderr management

Example: it stdout into a file his management:
1
ls -l > ls-l.txt

Example: it stderr into a file his management:
1
grep da * 2> grep-errors.txt

Example: it stdout into stderr his management:
1
grep da * 1>&2

Example: it stderr into stdout his management:
1
grep * 2>&1

Example: it stderr and stdout into a file his management:
1
rm -f $(find / -name core) &> /dev/null




EDIT: by Meka: Use code brackets for code.
I say thank you for it Meka, I admit it I was lazy, I am listening better another time. :)
Forum Index > Bash/Shell > Easy, introductory scripts