This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -print0 | grep -Z -z -v '^\.$' | xargs -0 stat -c '%a:%U:%G:%n' | perl -n -e '($p, $u, $g, $f) = (/(.*?):(.*?):(.*?):(.*)/); print "chown $u:$g \"$f\"\n"; print "chmod $p \"$f\"\n";' > /tmp/doit.sh | |
cd /path/to/source; find . -print0 | grep -Z -z -v '^\.$' | xargs -0 stat -c '%a:%U:%G:%n' | perl -n -e '($p, $u, $g, $f) = (/(.*?):(.*?):(.*?):(.*)/); `chown $u:$g "$f"`; `chmod $p "$f"`;' | ssh target_host 'cat > /tmp/doit.sh; cd /path/to/target; . /tmp/doit.sh; rm /tmp/doit.sh' | |
On the target: | |
cd /path/to/targetdir; find . -print0 | grep -Z -z -v '^\.$' | ssh source 'cd /path/to/sourcedir; xargs -0 stat -c "%a:%U:%G:%n"' | perl -n -e '($p, $u, $g, $f) = (/(.*?):(.*?):(.*?):(.*)/); `chown $u:$g "$f"`; `chmod $p "$f"`;' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ubuntu tree | |
sudo apt-get install tree | |
# print to terminal in tree format | |
$ tree [DIRECTORY] | |
# example [csv] directory outputs: | |
├── csv | |
│ ├── CVS | |
│ │ ├── Entries |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# the following sets up a bash script to write the -x tracing to a log file | |
# in /tmp, with a meaningful, unique name, and a trap to remove it if the | |
# script completes successfully. Therefore, if the script fails, in any | |
# way, the log is there to peruse. If it succeeds (exit 0) then nothing | |
# is left behind | |
# Set up a function to remove the trace file on successful run (exit 0) | |
cleanup_trace_file() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Complex Shell Script Outline | |
---------------------------- | |
header | |
begin script | |
preamble: | |
- sanity checks | |
- create shell environ | |
- log & debug | |
error handling | |
check dependencies |