Pages

Check the number of words/lines/characters in a file

You may know how to check the number of words/characters/lines in a MS Word file. But, how to check these in pdf file or any file?

Here comes the command "wc"

To use this, type the following command (for example to find the number of words in a pdf file).

wc -w fileName.pdf

This will return the number of words in the file.

Linux tips series

To replace the last command with the same arguments

commandName !*  - for all arguments
commandName !$  - for the last argument
commandName !:N - for the Nth argument



Using grep recursively

grep -r "text_to_grep" .
grep -r --include "*.txt" "text_to_grep" .
grep --include="*.csv" -nRHI "text_to_grep" *


After compiling a code, you may search for the executable (if you have a number of files in that directory). In this case, you can use ls -ltr to list all the files as per the time they are created. For example, see blwo.

gfortran -o code.out code.f90

If you run above line you will get the executable code.out in the same directory. But to look at this file, you can type,

ls -ltr

This will list all the files with code.out at the end of the list. This is a quick check for checking whether the executable is created or not. This will be useful when you teach or create a tutorial on coding.


Use top command to check which jobs are running.
Suppose you submit a job to compute in Linux. If you are not sure whether the job is completed or not, use 'top' command to check.

Type on the terminal
top

Now, you will get list of jobs running on the computer.
Then press 1 to see the latest jobs on top.




Viewing .jpg, .eps, .tif and .pdf files in Linux terminal

I mostly use .jpg, .eps, .tiff and .pdf formats for scientific publishing.

To open these files in Linux (Ubuntu)

For JPG files
eof fileName.jpg

For TIF files
eog fileName.tif

For .PNG files
eog fileName.png

For PDF files
evince fileName.pdf

For EPS files

You may be interested in these posts

Error in image file conversion: convert-im6.q16: not authorized `test.eps' @ error/constitute.c/WriteImage/1037.

This error is because of the vulnerability. This allows remote execution of code using image formats. So, some Linux distributions by defaul...