Sometimes we need to create a file that contains several random numbers. Using bash programming we can do that very quickly. Example,
mycomputer ~% for i in {1..1000}; do echo $RANDOM; done >> nums.txt
This command executes a for loop 1000 times, prints the random variable $RANDOM and redirect the output to the file nums.txt
Friday, June 24, 2016
Create a file with random numbers
Print a random integer in the bash console
If you need a random positive integer, you can print the variable $RANDOM. For example:
mycomputer ~% echo $RANDOM
120865
mycomputer ~% echo $RANDOM
120865
Saturday, April 25, 2015
Replace a string in several files
[CONTEXT]
You need to replace a string in several files
[HOW]
There several options to do this,
[SOURCE]
sed man page
http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/
You need to replace a string in several files
[HOW]
There several options to do this,
- sed: Syntax: $ sed -i "s/old_string/new_string/g" files
Example $ sed -i "s/foo/bar/g" *.txt - perl: Syntax: $ perl -i -p -e "s/old_string/new_string/g;" files
[SOURCE]
sed man page
http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/
Monday, August 25, 2014
Managing your latex bib files in linux II
[CONTEXT]
You want a program to manage your Latex bibliography file.
[HOW]
Jabref is a really good program to organize and modify your bib files in Latex using a very friendly GUI. Also this program can generate automatically the key for the bib entries and you can include the link to your pdf files.
To install it, we can use the package in Debian's repository
# aptitude install jabref
[SOURCE]
http://jabref.sourceforge.net/
You want a program to manage your Latex bibliography file.
[HOW]
Jabref is a really good program to organize and modify your bib files in Latex using a very friendly GUI. Also this program can generate automatically the key for the bib entries and you can include the link to your pdf files.
To install it, we can use the package in Debian's repository
# aptitude install jabref
[SOURCE]
http://jabref.sourceforge.net/
Synchronize a folder outside the default Dropbox's directory
[CONTEXT]
You want to synchronize a folder with Dropbox, without move that folder to
the default Dropbox's directory
[HOW]
Create a symbolic link from the folder that you want to synchronize to the Dropbox directory, for example
$ ln -s /path/to/folder/to/sync ~/Dropbox
[SOURCE]
http://www.dropboxwiki.com/tips-and-tricks/sync-other-folders
You want to synchronize a folder with Dropbox, without move that folder to
the default Dropbox's directory
[HOW]
Create a symbolic link from the folder that you want to synchronize to the Dropbox directory, for example
$ ln -s /path/to/folder/to/sync ~/Dropbox
The permissions of the files or folders should be (at least) owner:r/w, group r/w, and others: r
-rw-rw-r--
[SOURCE]
http://www.dropboxwiki.com/tips-and-tricks/sync-other-folders
Monday, December 2, 2013
Check infromation of CPU, memory and Hard Drive information
[CONTEXT]
In order to check the information of your CPU, memory and Disk usage.
[HOW]
To check your CPU information, just execute
$ cat /proc/cpuinfo
or
$ lscpu
To check your Memory information, just execute
$ cat /proc/meminfo
To check your Disk Usage information, just execute
$ df -h
[SOURCE]
man proc
man df
In order to check the information of your CPU, memory and Disk usage.
[HOW]
To check your CPU information, just execute
$ cat /proc/cpuinfo
or
$ lscpu
To check your Memory information, just execute
$ cat /proc/meminfo
To check your Disk Usage information, just execute
$ df -h
[SOURCE]
man proc
man df
Friday, October 11, 2013
Removing annoying console beeps
In order, to remove the beep sound of your linux console just type the following command, in your console (in the directory /home/$your_user)
$echo 'set bell-style none' >> ~/.inputrc
$echo 'set bell-style none' >> ~/.inputrc
Subscribe to:
Posts (Atom)