Skip to main content

4 posts tagged with "bash"

View All Tags

· One min read

One of the problems with working on Linux and Windows OSes has to do with manipulating text files. Lines are separated by a carriage return and a line break character in text files on Windows, whereas on Linux, the separation is done through a single line break character.

When text files from Windows are opened in Linux, you often see ^M appearing at the end of lines like this:

Line 1^M Line 2^M

The easiest way to remove the carriage return characters (represented by ^M) is to use the dos2unix command. This lightweight program can be easily obtained on Debian-based systems with the command:

sudo apt-get install dos2unix

Other than using the dos2unix command, the fastest way to remove the carriage return characters is the following command:

cat file1.txt | tr -d '\r' > file2.txt

· 2 min read

During the lifetime of using the computer, I believe everyone will inevitably face the scenario where you will want resize multiple images to a certain size.

In Linux, you can do it will such ease that makes you wonder what you use Windows for.

This effect can be easily done using the command line. Naysayers will probably disclaim the effectiveness of this tip but it really is easy for those who know Linux. All you have to do is to go into the directory where the images are stored and run the following command:

for k in $(ls *.jpg); do convert $k -resize 1024x768 -quality 100 re_$k; done