This command in one line allows to empty all the files (readable of cours) in a folder
find . -type f -exec sh -c '>{}' \;
This command in one line allows to empty all the files (readable of cours) in a folder
find . -type f -exec sh -c '>{}' \;
Issue when execute git diff command on a file and got :
diff --git a/your_file b/your_file old mode 100644 new mode 100755
If you see this, it is because the permissions of your_file has changed.
For information, the unix file permission mode(644=rw_r__r__ which means read and write for user, only read for group and only read for others, the same for 755=rwxrw_rw_, x for executable).
To disable the comparaison of file mode, the command to execute :
git config core.filemode false
Environment : Ubuntu 14.04
Problem :
As said the subject, we want to extract only the contents of a tar file to a specific folder.
I have my tar : myTarFolder.tar, my destination folder : destFolder
The structure of my tar file :
If we use only the tar command, we will get :
tar -xf myTarFolder.tar -C destFolder
If we want to get something like this :
The option that we have to use is :
An example of the command :
tar -xf myTarFolder.tar --strip-components=1 -C destFolder
The result :
The command allows display the content of a tar file without extracting, and with –exclude option which uses the pattern can also show the level you want to display.
Example :
tar --exclude="*/*/*" -tf yout_tar_file.tar.gz
tar command example
Continue reading
It’s not always easy to remember the name of file which contains exactly what we want to search.
In linux, we can search without knowing the name of the file with the command grep, and of course we should specify a path.
Continue reading
If you have met the same problem, this maybe help.
Background :
I installed phpunit in my ubuntu 12.04(the os is lubuntu), the installation passed quite well, but when I launch the command in termianl, I got always this warning :
$ phpunit --version WARNING: gnome-keyring:: couldn't connect to: /tmp/keyring-xAGrk8/pkcs11: No such file or directory PHPUnit 4.4.5 by Sebastian Bergmann.
# show the partitions sizes # (Filesystem, Size, Used, Avail, Use%, Mounted on) df -h # show directory size du -s -h /your_dir_name/ # show file size du -s -h your_file_name
Tips :
Linux commands are marvellous !
We can use LS to sort files by name, by size or others methods that you could imagine.
For example,
Suppose you have a list of files in a folder :
– cuibo1
– 1111
– 2222
– 3333
– cuibo2
– cuibo333
And you want all the files in order which begins with cuibo, what you can do is : ls -h | grep “cuibo”
C’est tout !
Here is a blog which talks about sort files by size : http://www.cyberciti.biz/faq/linux-ls-command-sort-by-file-size/