Ετήσια αρχεία: 2016


marits0ui on Instagram

Instagram profile page of <a href="https://www.instagram.com/marits0ui/" target="_blank">marits0ui</a>

Instagram profile page of marits0ui

Instagram profile page of <a href="https://www.instagram.com/marits0ui/" target="_blank">marits0ui</a>
Instagram profile page of <a href="https://www.instagram.com/marits0ui/" target="_blank">marits0ui</a>
Instagram profile page of <a href="https://www.instagram.com/marits0ui/" target="_blank">marits0ui</a>Previous Collection


Using .tgz files 1

Create

To create a .tgz file, we used tar with the following parameters -czf:

  • -c or --create will create a new archive.
  • -z– or --gzip or --gunzip or --ungzip will filter the archive through gzip and compress it.
  • -f or --file=ARCHIVE will use archive file or device ARCHIVE. If this option is not given, tar will first examine the environment variable TAPE. If it is set, its value will be used as the archive name. Otherwise, tar will assume the compiled-in default.

Example:


tar -czf $ARCHIVE_FILE_NAME.tgz $PATH_TO_COMPRESS;

Please note that the order of the parameters will not change the result.

Extract

To extract a .tgz or .tar.gz file using tar we used the following parameters -xzf:

  • -x or --extract --get will extract the files from the archive. Arguments are optional. When given, they specify names of the archive members to be extracted.
  • -z– or --gzip or --gunzip or --ungzip will filter the archive through gzip and decompress it.
  • -f or --file=ARCHIVE will use archive file or device ARCHIVE. If this option is not given, tar will first examine the environment variable TAPE. If it is set, its value will be used as the archive name. Otherwise, tar will assume the compiled-in default.

Example:


tar -xzf $ARCHIVE_FILE_NAME.tgz;


GNU/Linux find: Get results relative to the directory searching in, instead of directory shell is in

Recently we wanted to create a list of files that could be found in a specific folder.
For that list we wanted the paths of the files to be relative to the folder we were searching in, instead of them being relative to the folder our shell was currently in.

To achieve that, we used cd to navigate into that folder and searched from there locally.
We used a sub-shell to achieve this, which was not needed, but because we did not want to change the current directory of our shell, it was needed.

The command was as follows:

(cd toThe/Path/WeAre/Interested/In && find .)

instead of:

find toThe/Path/WeAre/Interested/In

Since we were interested in getting all files, we did not put any filters on find.
Of course you can use find normally and modify it as you please.

Finally, since we wanted the list of files to be saved in a text file, we redirected the output of the above command to a file in the current working directory

(cd toThe/Path/WeAre/Interested/In && find .) > interestingFiles.txt

Copy a symbolic link without traversing it

Recently we needed to copy a Symbolic Link on a disk image we would deploy on an embedded device.
For this reason it was important for us to copy the Symbolic Link and not the file it was pointing to as that link would become valid once the machine would boot from the image.

To achieve that we used -P which instructs cp to never follow symbolic links in source. In other words it would not traverse the symbolic link and copy the symbolic link itself.

Notes:

  • --no-dereference is the same as -P.
  • -P uses a capital P.