I've got a script that scp's a file from remote host back to local. Sometimes the file names contain spaces. scp does not like spaces in its file names.
Hello I'm doing a script for doing backups but i can only backup directories from / any other files for example /etc/X11 cannot be backed up. how do i solve this?
this is the code i'm using now:
#!/bin/bash
clear
read -p "Enter the directory to backup:" DIRECTORY
echo
echo "backing up $DIRECTORY"
OK, a little bit later than I should have replied, but I have incorporated the tips provided above, I have added an extra check for the target dir and I have applied general exit codes:#!/bin/bash
##
## VARIABLES
##
# Set source location
BACKUP_FROM="/srv/media/"
# Set target location
BACKUP_TO="/media/backup/media/"
BACKUP_DEV="xxxxxxx-xxxxx-xxxxxxxxxxxxxxx" #UUID
I understand that one technique for dealing with spaces in filenames is to enclose the file name with single quotes: "'".
Why is it that the following code called, "echo.sh" works on a directory containing filenames with spaces, but the program "ls.sh" does Not work, where the only difference is 'echo' replaced with 'ls'?
echo.sh
#!/bin/sh
for f in *
do
echo "'$f'"
done
Produces:
'a b c'
Hi,I have pretty much the same first problem.
Ok, I've made my first backup script to be run as a cron job. It tars three directories:
/etc -> /media/Storage/backup/etc.tar.bz2
/root -> /media/Storage/backup/home/root.tar.bz2
/home/matthew -> /media/Storage/backup/home/matthew.tar.bz2
etc.tar.bz2 and root.tar.bz2 come out ok, but matthew.tar.bz2 does not. it isn't corrupted, it
I've been using this line to remove spaces from file names in Linux.
Usually Windows users like to add spaces in the file names, I prefer dashes (-) or under scores (_) instead, they are easy to manage in the console.
I've found this command a long time ago in a forum, and still have it on my personal notes.
Here posted for everybody:
for file in *; do mv "$file" `echo $file | sed -e 's/ */_/g'
Hi all,
I have a simple script, which for sure i need to enhance more and more. For now, it is just making a compress file in tar.gz format in output dir.
Here is script:
Quote:
#!/bin/bash
#Defines output file
OUTPUT=/Documents/backup_$(date +%Y%m%d%H%M%S).tar.gz
#Defines directory to backup
I am trying to copy files using secure copy(scp).