Create a transparent image using ImageMagick
Answer:
You can use the following command to create an empty png file, using the ImageMagick.
# convert -size 100x100 xc:none empty.png
an empty png of size 100x100 will be created.
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
Create a transparent image using ImageMagick
Answer:
You can use the following command to create an empty png file, using the ImageMagick.
# convert -size 100x100 xc:none empty.png
an empty png of size 100x100 will be created.
Edit a remote file with vim over SSH
Answer:
If you have a remote file and you can have a quick edit, if you use the following command:
# ssh -t john@remote-server vim /data/test.txt
You will be prompted to login if you don't have proper ssh key in the remote server, and after finishing editing the file, you will quit the ssh session automatically.
Sort numerical value using the sort command
Answer:
Assume you have a text file contains the following content:
1
2
3
10
When you use the sort command to sort them, it will give the following output:
# sort test.txt
1
10
2
3
So you need to sort them according to the numerical values?
Try with the n flag:
# sort -n test.txt
1
2
3
10
Revert uncommitted change in Git
Answer:
To revert the changes of a uncommitted file in Git, you need to use the following command:
# git checkout file
Auto create complete directory structure when copying files in Linux
Answer:
Assume you are copying file using the command below:
# cp foo/bar/test.txt /tmp/
The result is test.txt will be placed inside the folder /tmp/.
In order to let the cp command auto create the foo/bar/ directory structure under /tmp, you can try the command:
# cp --parent foo/bar/test.txt /tmp/