LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-17-2009, 10:57 AM   #16
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670

You could use find's -print0 option, and pipe the output to 'xargs -0'. Look at the options for xargs, as it has options that limit the number of arguments that fill the argv array. This prevents a bash out of memory error.

Another option, if you want to backup from a list of files, is to use the `tr' command to replace newlines to nulls, and pipe the output to "xargs -0"
tr <filelist '\n' '0' | xargs -0 -L 1000 cp --target-directory="${target-directory}"

---

Also consider using tar or rsync to replicate files to a backup. Tar can use a snapshot file so that only new files are copied.

BACKUPDIR=/mnt/lacie/backups/
tar -C /home/sambashare/ -g timestamp.snar -cf - . | tar -C "${BACKUPDIR}/ -xvf - >logfile

Suppose you have a fileserver where you save backups to. You can backup to it via ssh even if it is somewhere out on the Internet:
eval $(ssh-agent)
ssh-add
<password>
tar -C /home/sambashare/ -g timestamp.snar -cf - . | ssh user@mrbackup tar -C "${BACKUPDIR}/" -xvf - >logfile
You want to use public key authentication for this.

Last edited by jschiwal; 07-17-2009 at 10:58 AM.
 
Old 07-17-2009, 11:00 AM   #17
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by arashi256 View Post
Yep.

Code:
./inc.sh: line 10: syntax error near unexpected token `<'
./inc.sh: line 10: `    done < <(cat FILE-LIST.tmp)'
Which shell are you using? It does not work in /bin/sh but in /bin/bash yes:
Code:
$ cat file.txt
My Documents
/home/colucix/name with spaces/file
$ while read filename; do echo "$filename"; done < <(cat file.txt)
My Documents
/home/colucix/name with spaces/file
 
Old 07-17-2009, 11:07 AM   #18
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 394

Original Poster
Rep: Reputation: 61
Okay, fixed it.

I had to temporarily surpress the IFS default bash "field separator" enviroment variable before doing my thing. Took out the sed stuff as it wasn't necessary as long as I enclosed stuff with spaces in double-quotes.

Thanks all.

Code:
IFS=; for filename in $(cat ~/FILE-LIST.tmp)
do
    # Do stuff...
done
 
Old 07-17-2009, 12:03 PM   #19
gulfax
LQ Newbie
 
Registered: Oct 2005
Location: malmoe, sweden
Distribution: opensuse 11.1
Posts: 4

Rep: Reputation: 0
Double quoting the $(...) construct in the for-loop should fix it, i.e.
for filename in "$(cat ~/FILE-LIST.tmp)"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] echoing whitespace from a command substitution GahseyFan Linux - General 2 05-16-2009 05:58 AM
Problems with a substitution using sed wtaicken Programming 4 12-15-2008 05:04 AM
sed, replacing underscore with whitespace fjkum Programming 3 10-31-2007 01:09 AM
Whitespace parsing sed? carl.waldbieser Programming 1 12-12-2005 05:24 PM
Using sed in bash to remove whitespace jimieee Programming 3 01-28-2004 11:33 AM


All times are GMT -5. The time now is 09:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration