Tar command in a bash script [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this question











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
If this question can be reworded to fit the rules in the help center, please edit the question.








  • 2




    It looks like your script is not assigning values to fdest or fname
    – 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. 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














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.







share|improve this question











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
If this question can be reworded to fit the rules in the help center, please edit the question.








  • 2




    It looks like your script is not assigning values to fdest or fname
    – 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. 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












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.







share|improve this question











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.









share|improve this question










share|improve this question




share|improve this question









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
If this question can be reworded to fit the rules in the help center, please edit the question.




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
If this question can be reworded to fit the rules in the help center, please edit the question.







  • 2




    It looks like your script is not assigning values to fdest or fname
    – 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. 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












  • 2




    It looks like your script is not assigning values to fdest or fname
    – 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. 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







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










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!






share|improve this answer





















  • 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

















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!






share|improve this answer





















  • 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














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!






share|improve this answer





















  • 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












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!






share|improve this answer













As the comments said, my scripts wasn't assigning values to my variables. I have now fixed that. Thanks a lot!







share|improve this answer













share|improve this answer



share|improve this answer











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
















  • 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


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Christian Cage

How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?