$ ln -nsf <TARGET> <LINK>
Credit: Commandline-fu.
29 Monday Aug 2011
$ ln -nsf <TARGET> <LINK>
Credit: Commandline-fu.
26 Friday Aug 2011
Tags
array, associative array, editor, env, environment variable, hash, perl, scripting, shell, shell variable, variable
The environmental variables are stored in %ENV hash (“associative array”). Now if you want to access a shell variable, say $HOME, in your Perl script, then you need to refer to it as $ENV{'HOME'}:
#!/usr/bin/perl
$my_home_dir = "$ENV{'HOME'}" ;
$my_shell = "$ENV{'SHELL'}" ;
$my_editor = "$ENV{'EDITOR'}" ;
Don’t forget the curly braces and the single quotes!
Reference: Devdaily blog.
25 Friday Mar 2011
Resize a picture or PDF file by 50% of its original form and save it as a PDF:
$ convert rose.jpg -resize 50% rose.pdf
Well, ‘convert’ may be used to convert between most of the known image formats —- not just JPG and PDF!
N.B. 1. More options may be found at the ImageMagick website. More information on how to specify the geometry may be found here. (If you don’t have ImgeMagick you need to install it first — see the first link for more information on installation!).
2. Here is a list of other useful options/ examples on how to make the best out of ‘convert’.
3. If you’re at playing with PDFs you may also be interested in joining and removing pages from a PDF document using Ghostscript — see a previous post here.
23 Wednesday Mar 2011
Posted in fortran, programming
Tags
character, f77, fortran, fortran 77, integer to character, integer to string, programming, string
Let’s assume that we have defined two strings as
str1 = 'abc'
str2 = 'pqr'
and an integer
integ = 25
(Make sure str1 and str2, and integ are defined as character strings, and integer, respectively)
1. Concatenate str1 and str2 into str3 (make sure you define str3 first as a character string)
str3 = str1//str2
2. Concatenate str1 and integ into str3 (again make sure str3 is defined as a character string)
step a: convert integer to a string first (make sure str4 is defined as a character string and not initialized, i.e. it’s so far an empty string)
write(str4,'(I5)') integ
step b: concatenate str1 and str4 into str3
str3 = str1//str4
13 Sunday Mar 2011
If you want to replace dots in a string, for example “a.string.with.dots”, by hyphens use the following trick
$ echo "a.string.with.dots" | tr "." "-"
That’s it!
Needless to say, other characters may also be substituted this way.