I created a cron task in the hosting of my website. I use this command:
zip -r public_html.zip public_html -x *public_html/cache/smarty*
As you can see I'm trying to zip the public_html excluding the folder: public_html/cache/smarty
The zip is created but I can not get to exclude the folder.
What am I missing here?
try this:
zip -r public_html.zip public_html -x *cache/smarty/*
Related
I want to achieve the following (simple) task, but I don't know how...
I have a zip file like this, only containing some folders
dummy.zip:
/my/dummy/folder/stucture
how can I add folders to this dummy.zip file that the newly added files and dirs are located under "/my/dummy/folder/stucture" using the command line (linux)?
dummy.zip should look like this afterwards:
/my/dummy/folder/stucture/my/new/Dirs
I've made a screenshot to better illustrate what I mean
To append "archive" to an existing zip file you could use option -r:
zip -r9 dummy.zip dirs
You could crate your zip:
$ zip -9 dummy.zip file
And later you could add a full dir:
$ zip -r9 dummy.zip dirs
Or contents of the dir on the same root:
$ cd dirs
$ zip -r9 dummy.zip *
The -9 is the compression level, in this case, the maximum.
If you have the original folder which you generated the first zip from, you can add the folder/files you want and then use the option -u from the zip command.
This option will update the zip with the newly added folders and files, you can use it like:
$> mkdir /my/dummy/folder/stucture/my/new/Dirs
$> zip -u dummy.zip /my/dummy
For example i have folder "admin" which contains folder "1" and two php files "index.php" and "page.php". I try to use tar -zcvf admin.tar.gz admin and got admin.tar.gz archive. If i open this archive, i can see archive contains "admin" folder and inside this directory is folder "1" and two php files.
I want to create tar.gz archive with all files and folders, but without parent folder. Create archive and it contains only folder "1" and two php files. How i can do it?
You can use the -C option:
tar -C admin -zcvf admin.tar.gz .
See man tar
-C, --directory=DIR
Change to DIR before performing any operations.
This option is order-sensitive, i.e. it affects all options that follow.
What's the Command in CentOS to purge/delete all contents in ALL "public_html" folders for all users at once? (I have my web server that I just cloned to make it into a mail server, but I don't want too keep all the public_html files)
Well, if all the files are under /home and you want to remove all the contents of /home/*/public_html you could do
rm -rf /home/*/public_html/*
By default wget -r downloads directories as directoryname.html. I'd like it to download to directoryname/index.html
So instead of:
index.html
contact.html
support.html
I'd like:
index.html
contact/index.html
support/index.html
Is this posible with wget?
When I want to mirror a web site I use:
$ wget -m -E -nH -np --cut-dirs=2 http://site/a/b/
This way everything under the directory "b" will be downloaded. If your target directory is at a different level, you need to adjust --cut-dirs accordingly.
I'm writing a PHP script that downloads a series of generated files (using wget) into a directory, and then zips then up, using the zip command.
The downloads work perfectly, and the zipping mostly works. I run the command:
zip -r /var/www/oraviewer/rgn_download/download/fcst_20100318_0319.zip /var/www/oraviewer/rgn_download/download/fcst_20100318_0319
which yields a zip file with all the downloaded files, but it contains the full /var/www/oraviewer/rgn_download/download/ directories, before reaching the fcst_20100318_0319/ directory.
I'm probably just missing a flag, or something small, from the zip command, but how do I get it to use fcst_20100318_0319/ as the root directory?
I don't think zip has a flag to do that. I think the only way is something like:
cd /var/www/oraviewer/rgn_download/download/ && \
zip -r fcst_20100318_0319.zip fcst_20100318_0319
(The backslash is just for clarity, you can remove it and put everything on one line.)
Since PHP is executing the command in a subshell, it won't change your current directory.
I have also get it worked by using this command
exec('cd '.$_SERVER['DOCUMENT_ROOT'].' && zip -r com.zip "./"');
cd /home/public_html/site/upload/ && zip -r sub_upload.zip sub_upload/
Use the -j or --junk-paths option in your zip command.
From the zip man page:
-j
--junk-paths
Store just the name of a saved file (junk the path), and do not store
directory names. By default, zip will store the full path (relative
to the current directory).