Search

Using enchant to spell check on the command line

Spell check is a common operation on all text files. All the editors come with built in spell checkers. But if we want to run a spell check on a text document with out opening it we can use enchant.

enchant is a command to check spelling, and also suggest the possible correct spellings. To only list the misspelt words we can use the option -l with the command

Let us say we have a file with the following text in a file called temp



To run a spell check on the file we can use enchant.



We can see that we have list of words that have been misspelled.

To get the line numbers in which the misspelled words are present we can use the option -L.



The first column is the line numbers and the second column the line numbers.

To get suggestions on possible corrections we can use the option -a.



Every line that starts with a & is the output for a misspelled word. The misspelled word is followed by all the possible suggestions.

error: ‘SPIN_LOCK_UNLOCKED’ undeclared here (not in a function)

While writing a kernel module using the spin locks in linux, we might hit the error



This might happen if we are trying to compile the module for kernel version below 3.0 Because before kernel version 3.0 SPIN_LOCK_UNLOCKED was defined in spinlock.h



But this definition is no longer available, and is replaced by DEFINE_SPINLOCK in spinlock_types.h



Thus in the module remove the initialization with SPIN_LOCK_UNLOCKED and add the macro DEFINE_SPINLOCK to get around the error.

Using the watch command to run a script or command periodically

At times we need to run certain commands repeatedly and watch the output. It could be as simple as looking into the log files, to running some scripts.

For such repeated running of commands we can use the command watch.

Watch is a command that runs a command periodically at fixed intervals untill not stopped.

For example



The command "echo hello" will be run every two seconds and the output displayed on the terminal. The previous output will be replaced by the new output, thus in this case we will not see any change in the output.To quit we can use the keys "Ctrl + C".

To be able to see clearly the repeation of the command let us create a file called temp,using gedit, and enter the text "Hello" in it. Save the file and in the terminal go to the folder where the file is stored. Now execute the command



Now go back to the file and add the text "world" to it and save it. Go back to the teminal and see the change in the output.



We can see the updated text appear in the output.

By default the watch executes the command every 2 seconds, but that can be changed using the option "-n"



To be able to see the differences between consecutive outputs, we can make watch to highlight the differences in the output using the option -d

This option -d is very useful when we want to contiously look at logs and find out differences between two consecutive logs.

If we do not want to see the heading line which indicates the repetion interval, the command and the current time we can use the option -t.