Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a tar ball in a shell script (I have enabled set -x), but I get an error:

+ cd /home5/mysite/public_html
+ TAR_DUMP=gypo_2012-02-18-03:51:15.tar.gz
+ echo 'Tar name: gypo_2012-02-18-03:51:15.tar.gz'
Tar name: gypo_2012-02-18-03:51:15.tar.gz
+ tar -cvzf gypo_2012-02-18-03:51:15.tar.gz gypo
tar: gypo_2012-02-18-03\:44\:04.tar.gz: Cannot open: Input/output error
tar: Error is not recoverable: exiting now

The script is the following:

NOW=$(date +"%Y-%m-%d-%T")


cd $HOME/public_html
echo "Tar name: $TAR_DUMP"
tar -cvzf $TAR_DUMP gypo
# mv -t $DEST $TAR_DUMP

Why is tar generating this error and how can I solve it? Thanks.

share|improve this question
up vote 5 down vote accepted

The : in the filename are confusing tar. At least for the coreutils version of tar, the --file switch can take an argument of the form:


so I'm guessing tar is trying to interpret that filename in a manner that is not what you meant.

Prefixing the file name with ./ (or specifying a full path) should solve your problem.

echo "Tar name: $TAR_DUMP"
tar -cvzf $TAR_DUMP gypo

Another fix would be to add the --force-local switch.


Forces `tar' to interpret the filename given to --file as a local file, even if it looks like a remote tape drive name.

share|improve this answer
Adding ./ solved the issue, many many thanks !!! – JVerstry Feb 18 '12 at 11:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.