2

I am using 7zip on my centos machine and ziping a file via command line.

This is my syntax

7za a -t7z backup.7z public_html\ -mx0 -xr!restricted_area

What i'm expecting with this syntax is to backup all files in public_html folder then exclude restricted_area folder, I am not really sure if this is correct, but the problem is I am getting this error:

-bash: !restricted_area: event not found

What does this suppose to mean? And also, Is my zipping syntax correct?

  • 2
    Escape the !. – Kevin Jun 6 '13 at 2:51
4

! begins a shell history expansion. In particular, !foo expands to the last command you wrote that begins with foo. As you don't have any commands in your history that begin with restricted_area, bash is giving you an error. You can get around this by escaping or quoting the !:

7za ... -xr\!restr...
7za ... -xr'!'restr...
7za ... '-xr!restr...'

For more information, see the bash man page under History Expansion -> Event Designators.

  • If I want to exclude other directories, should I just repeat the -xr\! and replace the 'restricted_area' into the directory that i want to exclude? – PinoyStackOverflower Jun 6 '13 at 3:05
  • I'm not familiar with the 7zip syntax, but if you have more !s, you will need to escape them as well. – Kevin Jun 6 '13 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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