Tar command in a bash script [closed]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm using the command in a script:
tar -czf -"$fsrc"/* > ./"$fdest"/"$fname"
In a script to take user defined source folder and redirect to a user defined destination with a user defined name.
When I use the command in the terminal by itself like:
tar -czf - Documents/* >./backup/test.tar.gz
It works fine but when run in my script I get:
archive.sh: line 172: .//: Is a directory
And nothing happens.
shell-script tar
closed as off-topic by roaima, DopeGhoti, Kusalananda, Jeff Schaller, steve Jun 26 at 18:10
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." â roaima, DopeGhoti, Kusalananda, Jeff Schaller, steve
add a comment |Â
up vote
0
down vote
favorite
I'm using the command in a script:
tar -czf -"$fsrc"/* > ./"$fdest"/"$fname"
In a script to take user defined source folder and redirect to a user defined destination with a user defined name.
When I use the command in the terminal by itself like:
tar -czf - Documents/* >./backup/test.tar.gz
It works fine but when run in my script I get:
archive.sh: line 172: .//: Is a directory
And nothing happens.
shell-script tar
closed as off-topic by roaima, DopeGhoti, Kusalananda, Jeff Schaller, steve Jun 26 at 18:10
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." â roaima, DopeGhoti, Kusalananda, Jeff Schaller, steve
2
It looks like your script is not assigning values tofdest
orfname
â steeldriver
Jun 26 at 15:42
2
Immediately above thetar
line you should consider a debugging statement such as"echo fsrc='$fsrc', fdest='$fdest', fname='$fname'"
and then fix your code appropriately
â roaima
Jun 26 at 15:45
Or useset -x
so that you are shown exactly what your script is trying to do before it does it. Orset -u
to abort with error if trying to reference an unset variable.
â DopeGhoti
Jun 26 at 15:46
You're right my script wasn't assigning values to my variables. Fixed now. Thank you!
â Drunkpacman
Jun 26 at 16:04
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using the command in a script:
tar -czf -"$fsrc"/* > ./"$fdest"/"$fname"
In a script to take user defined source folder and redirect to a user defined destination with a user defined name.
When I use the command in the terminal by itself like:
tar -czf - Documents/* >./backup/test.tar.gz
It works fine but when run in my script I get:
archive.sh: line 172: .//: Is a directory
And nothing happens.
shell-script tar
I'm using the command in a script:
tar -czf -"$fsrc"/* > ./"$fdest"/"$fname"
In a script to take user defined source folder and redirect to a user defined destination with a user defined name.
When I use the command in the terminal by itself like:
tar -czf - Documents/* >./backup/test.tar.gz
It works fine but when run in my script I get:
archive.sh: line 172: .//: Is a directory
And nothing happens.
shell-script tar
asked Jun 26 at 15:40
Drunkpacman
233
233
closed as off-topic by roaima, DopeGhoti, Kusalananda, Jeff Schaller, steve Jun 26 at 18:10
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." â roaima, DopeGhoti, Kusalananda, Jeff Schaller, steve
closed as off-topic by roaima, DopeGhoti, Kusalananda, Jeff Schaller, steve Jun 26 at 18:10
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." â roaima, DopeGhoti, Kusalananda, Jeff Schaller, steve
2
It looks like your script is not assigning values tofdest
orfname
â steeldriver
Jun 26 at 15:42
2
Immediately above thetar
line you should consider a debugging statement such as"echo fsrc='$fsrc', fdest='$fdest', fname='$fname'"
and then fix your code appropriately
â roaima
Jun 26 at 15:45
Or useset -x
so that you are shown exactly what your script is trying to do before it does it. Orset -u
to abort with error if trying to reference an unset variable.
â DopeGhoti
Jun 26 at 15:46
You're right my script wasn't assigning values to my variables. Fixed now. Thank you!
â Drunkpacman
Jun 26 at 16:04
add a comment |Â
2
It looks like your script is not assigning values tofdest
orfname
â steeldriver
Jun 26 at 15:42
2
Immediately above thetar
line you should consider a debugging statement such as"echo fsrc='$fsrc', fdest='$fdest', fname='$fname'"
and then fix your code appropriately
â roaima
Jun 26 at 15:45
Or useset -x
so that you are shown exactly what your script is trying to do before it does it. Orset -u
to abort with error if trying to reference an unset variable.
â DopeGhoti
Jun 26 at 15:46
You're right my script wasn't assigning values to my variables. Fixed now. Thank you!
â Drunkpacman
Jun 26 at 16:04
2
2
It looks like your script is not assigning values to
fdest
or fname
â steeldriver
Jun 26 at 15:42
It looks like your script is not assigning values to
fdest
or fname
â steeldriver
Jun 26 at 15:42
2
2
Immediately above the
tar
line you should consider a debugging statement such as "echo fsrc='$fsrc', fdest='$fdest', fname='$fname'"
and then fix your code appropriatelyâ roaima
Jun 26 at 15:45
Immediately above the
tar
line you should consider a debugging statement such as "echo fsrc='$fsrc', fdest='$fdest', fname='$fname'"
and then fix your code appropriatelyâ roaima
Jun 26 at 15:45
Or use
set -x
so that you are shown exactly what your script is trying to do before it does it. Or set -u
to abort with error if trying to reference an unset variable.â DopeGhoti
Jun 26 at 15:46
Or use
set -x
so that you are shown exactly what your script is trying to do before it does it. Or set -u
to abort with error if trying to reference an unset variable.â DopeGhoti
Jun 26 at 15:46
You're right my script wasn't assigning values to my variables. Fixed now. Thank you!
â Drunkpacman
Jun 26 at 16:04
You're right my script wasn't assigning values to my variables. Fixed now. Thank you!
â Drunkpacman
Jun 26 at 16:04
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
As the comments said, my scripts wasn't assigning values to my variables. I have now fixed that. Thanks a lot!
You might want to mark this as the correct answer.
â steve
Jun 26 at 18:01
1
It won't let me accept my own answer for another 2 days.
â Drunkpacman
Jun 26 at 18:09
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
As the comments said, my scripts wasn't assigning values to my variables. I have now fixed that. Thanks a lot!
You might want to mark this as the correct answer.
â steve
Jun 26 at 18:01
1
It won't let me accept my own answer for another 2 days.
â Drunkpacman
Jun 26 at 18:09
add a comment |Â
up vote
2
down vote
As the comments said, my scripts wasn't assigning values to my variables. I have now fixed that. Thanks a lot!
You might want to mark this as the correct answer.
â steve
Jun 26 at 18:01
1
It won't let me accept my own answer for another 2 days.
â Drunkpacman
Jun 26 at 18:09
add a comment |Â
up vote
2
down vote
up vote
2
down vote
As the comments said, my scripts wasn't assigning values to my variables. I have now fixed that. Thanks a lot!
As the comments said, my scripts wasn't assigning values to my variables. I have now fixed that. Thanks a lot!
answered Jun 26 at 16:05
Drunkpacman
233
233
You might want to mark this as the correct answer.
â steve
Jun 26 at 18:01
1
It won't let me accept my own answer for another 2 days.
â Drunkpacman
Jun 26 at 18:09
add a comment |Â
You might want to mark this as the correct answer.
â steve
Jun 26 at 18:01
1
It won't let me accept my own answer for another 2 days.
â Drunkpacman
Jun 26 at 18:09
You might want to mark this as the correct answer.
â steve
Jun 26 at 18:01
You might want to mark this as the correct answer.
â steve
Jun 26 at 18:01
1
1
It won't let me accept my own answer for another 2 days.
â Drunkpacman
Jun 26 at 18:09
It won't let me accept my own answer for another 2 days.
â Drunkpacman
Jun 26 at 18:09
add a comment |Â
2
It looks like your script is not assigning values to
fdest
orfname
â steeldriver
Jun 26 at 15:42
2
Immediately above the
tar
line you should consider a debugging statement such as"echo fsrc='$fsrc', fdest='$fdest', fname='$fname'"
and then fix your code appropriatelyâ roaima
Jun 26 at 15:45
Or use
set -x
so that you are shown exactly what your script is trying to do before it does it. Orset -u
to abort with error if trying to reference an unset variable.â DopeGhoti
Jun 26 at 15:46
You're right my script wasn't assigning values to my variables. Fixed now. Thank you!
â Drunkpacman
Jun 26 at 16:04