LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 08-12-2012, 05:25 AM   #16
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 594

Rep: Reputation: 141Reputation: 141

Quote:
Originally Posted by jschiwal View Post
If the arguments are to be evaluated locally, by bash, then the wild cards and brace expansion shouldn't be in quotes.
If you precede a connand with set, you can examine the arguments $1, $2, etc. to verify what arguments the command sees after bash performs the various expansions.
change
Code:
SOURCE="{argomentare,bibliografie,documenti}"
in
SOURCE={argomentare,bibliografie,documenti}
 
Old 08-12-2012, 05:37 AM   #17
samiel
LQ Newbie
 
Registered: Aug 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
No, already tried:
Code:
samiel@debian:~$ bash -x backup.sh
+ SOURCE='{argomentare,bibliografie,documenti}'
+ TARGET=/media/CORSAIR
++ date +%y-%M-%D
+ date=12-35-08/12/12
+ TAG=backup
+ mount
+ grep -q /media/CORSAIR
+ echo 'Il disco è montato: eseguo il backup'
Il disco è montato: eseguo il backup
++ hostname
+ logger Inizio backup di '{argomentare,bibliografie,documenti}' per debian -t backup
+ rsync -rvu --progress '{argomentare,bibliografie,documenti}' /media/CORSAIR
sending incremental file list
rsync: link_stat "/home/samiel/{argomentare,bibliografie,documenti}" failed: No such file or directory (2)

sent 12 bytes  received 12 bytes  48.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]
++ hostname
+ logger Fine backup per debian: rsync ha restituito -t backup
+ exit 0
S
 
Old 08-12-2012, 08:34 AM   #18
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,009

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Ok ... so now I think I am following a little better (sorry it took a while).

So on the command line you use brace expansion to list your multiple directories in the current path. So my suggestion still holds that an array would probably suit.
I do however still think the earlier suggestion of an include or exclude file would make this simpler.

However, the array suggestion would work like so:
Code:
SOURCE=( argomentare bibliografie documenti )
TARGET=/media/CORSAIR

rsync -rvu --progress ${SOURCE[@]} $TARGET
I will let you worry about the rest of your code but you should get the general idea.
 
Old 08-12-2012, 08:37 AM   #19
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 594

Rep: Reputation: 141Reputation: 141
Or change
Code:
SOURCE="{argomentare/*,articoli/*}"
SOURCE=$(echo {argomentare/*,articoli/*})
 
Old 08-13-2012, 06:09 AM   #20
samiel
LQ Newbie
 
Registered: Aug 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Now working !!
Only a last proble. For I've a lot of directories,
I must split comman on more lines. In the script,
the backslash doesn't seem to work:
Code:
SOURCE=( argomentare,bibliografie,cataloghi,condominio,copertine,cratilo, \
dialettica,dizionario,documenti,elisp,ermeneutica,esperienza,ezine,fichte, \
filosofi,guide_debian,guide_latex,guide_linux,guide_php,guide_slackware, \
html4dummies,mail,manuale,mutt4dummies,neopositivisti,noneuclidee,novecento, \
protagonisti,protagonisti_nuovo,public_html,retorica,s4d_project,sabina, \
sacchettino,Scaricati,schelling,scuola,slack4dummies,slackbook,songs,storia, \
tesi,texmf, tin4dummies,tractatus,xindy )
How to splt correctly this variable?

Thanx
S
 
Old 08-13-2012, 07:32 AM   #21
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,009

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
No backslash required The array is happy to use any white space.

As you list is quite large (and potentially growing??) I would urge you to look at the include file idea.
 
Old 08-13-2012, 12:21 PM   #22
samiel
LQ Newbie
 
Registered: Aug 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
However
Code:
#!/bin/bash

SOURCE=( argomentare,bibliografie,cataloghi )
TARGET="/media/CORSAIR"
rsync -rvu --progress ${SOURCE[@]} $TARGET
works fine, while
Code:
#!/bin/bash
SOURCE=( argomentare,bibliografie,cataloghi,condominio,copertine,cratilo,
dialettica,dizionario,documenti,elisp,ermeneutica,esperienza,ezine,fichte,
filosofi,guide_debian,guide_latex,guide_linux,guide_php,guide_slackware,
html4dummies,mail,manuale,mutt4dummies,neopositivisti,noneuclidee,novecento,
protagonisti,protagonisti_nuovo,public_html,retorica,s4d_project,sabina,
sacchettino,Scaricati,schelling,scuola,slack4dummies,slackbook,songs,storia,
tesi,texmf, tin4dummies,tractatus,xindy )
TARGET="/media/CORSAIR"
rsync -rvu --progress ${SOURCE[@]} $TARGET
give me this error:
Code:
samiel@debian:~$ bash -x backup.sh
+ SOURCE=(argomentare,bibliografie,cataloghi,condominio,copertine,cratilo, dialettica,dizionario,documenti,elisp,ermeneutica,esperienza,ezine,fichte, filosofi,guide_debian,guide_latex,guide_linux,guide_php,guide_slackware, html4dummies,mail,manuale,mutt4dummies,neopositivisti,noneuclidee,novecento, protagonisti,protagonisti_nuovo,public_html,retorica,s4d_project,sabina, sacchettino,Scaricati,schelling,scuola,slack4dummies,slackbook,songs,storia, tesi,texmf, tin4dummies,tractatus,xindy)
+ TARGET=/media/CORSAIR
+ rsync -rvu --progress argomentare,bibliografie,cataloghi,condominio,copertine,cratilo, dialettica,dizionario,documenti,elisp,ermeneutica,esperienza,ezine,fichte, filosofi,guide_debian,guide_latex,guide_linux,guide_php,guide_slackware, html4dummies,mail,manuale,mutt4dummies,neopositivisti,noneuclidee,novecento, protagonisti,protagonisti_nuovo,public_html,retorica,s4d_project,sabina, sacchettino,Scaricati,schelling,scuola,slack4dummies,slackbook,songs,storia, tesi,texmf, tin4dummies,tractatus,xindy /media/CORSAIR
sending incremental file list
rsync: link_stat "/home/samiel/argomentare,bibliografie,cataloghi,condominio,copertine,cratilo," failed: No such file or directory (2)
rsync: link_stat "/home/samiel/dialettica,dizionario,documenti,elisp,ermeneutica,esperienza,ezine,fichte," failed: No such file or directory (2)
rsync: link_stat "/home/samiel/filosofi,guide_debian,guide_latex,guide_linux,guide_php,guide_slackware," failed: No such file or directory (2)
rsync: link_stat "/home/samiel/html4dummies,mail,manuale,mutt4dummies,neopositivisti,noneuclidee,novecento," failed: No such file or directory (2)
rsync: link_stat "/home/samiel/protagonisti,protagonisti_nuovo,public_html,retorica,s4d_project,sabina," failed: No such file or directory (2)
rsync: link_stat "/home/samiel/sacchettino,Scaricati,schelling,scuola,slack4dummies,slackbook,songs,storia," failed: No such file or directory (2)
rsync: link_stat "/home/samiel/tesi,texmf," failed: No such file or directory (2)
rsync: link_stat "/home/samiel/tin4dummies,tractatus,xindy" failed: No such file or directory (2)

sent 12 bytes  received 12 bytes  48.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]
samiel@debian:~$ bash -x backup.sh
+ SOURCE=(argomentare,bibliografie,cataloghi)
+ TARGET=/media/CORSAIR
+ rsync -rvu --progress argomentare,bibliografie,cataloghi /media/CORSAIR
sending incremental file list
rsync: link_stat "/home/samiel/argomentare,bibliografie,cataloghi" failed: No such file or directory (2)

sent 12 bytes  received 12 bytes  48.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]
S
 
Old 08-14-2012, 12:36 AM   #23
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,009

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
I did not notice previously, but you have placed commas in the array and hence rendered it not an array but a single string. Now that you have the new lines
being interpreted as white space it breaks the array into pieces based on the new line. The commas were required when you used {} as this indicates how to expand the
braces in the shell, ie where a word ends, but an array uses white space.

Try replacing all commas with a space. Obviously if any of your file / directory names have a space in them this will cause issues. Again why I would recommend the include file.
 
Old 08-14-2012, 04:19 PM   #24
samiel
LQ Newbie
 
Registered: Aug 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Perfect.. Now I'll try
with include file too...

Thanx !!

S

Last edited by samiel; 08-14-2012 at 04:40 PM.
 
Old 08-31-2012, 01:21 PM   #25
samiel
LQ Newbie
 
Registered: Aug 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Very strange, I used tthe script but tonight with
Code:
#!/bin/bash
SOURCE=( .abook argomentare bibliografie cataloghi condominio copertine
cratilo dialettica dizionario documenti elisp ermeneutica esperienza ezine
fichte filosofi guide_debian guide_latex guide_linux guide_php guide_slackware
html4dummies mail manuale mutt4dummies neopositivisti noneuclidee novecento
protagonisti protagonisti_nuovo public_html retorica s4d_project sabina
sacchettino Scaricati schelling scuola slack4dummies slackbook songs storia
tesi texmf tin4dummies tractatus xindy .bashrc .vimrc backup.sh )
TARGET="/media/CORSAIR"
rsync -rvuz --delete --delete-after --progress ${SOURCE[@]} $TARGET
I receive
Code:
samiel@debian:~$ sh backup2.sh 
backup2.sh: 2: backup2.sh: Syntax error: "(" unexpected
and don't uunderstand what's happened...

S
 
Old 09-01-2012, 12:52 AM   #26
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,009

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Try placing set -xv as second line in script and check the output.

Also, by calling the script with sh you may limit some of bash's features. Simply make it executable and run it.

Last edited by grail; 09-01-2012 at 12:53 AM.
 
Old 09-01-2012, 01:48 AM   #27
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
@samiel: I think you mean the use of arrays instead.
Code:
SOURCE=("argomentare" "bibliografie" "documenti") # quotes not necessary unless you have white spaces
rsync -rvu --progress "${SOURCE[@]}" "$TARGET/"
 
  


Reply



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
Script to Hit 'Enter' key multiple times in bash script. nithinmp Ubuntu 7 07-19-2012 07:01 AM
[SOLVED] Run multiple bash and php scripts from a bash script charu Programming 5 07-26-2011 02:40 AM
Bash script: how do I select second-to-last argument in a list Robert S Linux - Software 2 11-23-2007 03:06 PM
Bash script to strip a certain directory out of directories in a directory? rylan76 Linux - General 3 08-29-2006 11:35 AM
making select show its menu in a bash script? zidane_tribal Programming 6 05-02-2005 05:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:41 AM.

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
Open Source Consulting | Domain Registration