Thursday, August 22, 2019
AWK Associative array
Monday, April 8, 2019
rename Command
$ rename --version
rename from util-linux 2.33.1
Perl based rename has below type of version.
$ rename --version
perl-rename 1.9
Syntax : rename 'old pattern' 'new pattern' input files
rename 'txt' 'text' *.txt
Sunday, April 7, 2019
What is .Vimrc file
- User vimrc
- System vimrc
- User vimrc in $HOME (The user vimrc file often does not exist until created by the user. If you cannot find $HOME/.vimrc (or $HOME/_vimrc on Windows) then you can, and probably should, just create it.)
- The system vimrc is normally under /etc in linux. The system vimrc should normally be left unmodified and it is not a good place you keep your personal settings. If you modify this file your changes may be overwritten if you ever upgrade vim. Also, changes here will affect other users on a multi-user system. In most cases, settings in the user vimrc will override settings in the system vimrc.
Thursday, April 4, 2019
AWK match and substr function
Search string for the longest, leftmost substring matched by the regular expression and return the character position (index) at which that substring begins (one, if it starts at the beginning of string). If no match is found, return zero.
The regexp argument may be either a regexp constant (/…/) or a string constant ("…").
The match() function sets the predefined variable RSTART to the index. It also sets the predefined variable RLENGTH to the length in characters of the matched substring. If no match is found, RSTART is set to zero, and RLENGTH to -1.
SUBSTR Function
example:
AB: 20190131 13 J-1|19:30:00.000000000 18:06:00.000000000 123466 50 @TEST . "" 1234 - I . ".." "" "" "TEST TEXT 1" "TEXT 2: SAMPLE TEXT I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find f.==Required file.csv.gz FIELD*SERVER-TIME*05:29:51.981378000" "" NoTime
Command : awk 'match($0,/==.*?.csv.gz/){print $3","substr($0, RSTART+2, RLENGTH-2)}' Sample file
Output : 13,Required file.csv.gz
Monday, March 4, 2019
What is Interpreter and Complier
Interpreter |
Compiler |
Translates program one statement at a time. |
Scans the entire program and translates it as a whole into machine code. |
It takes less amount of time to analyze the source code but the overall execution time is slower. |
It takes large amount of time to analyze the source code but the overall execution time is comparatively faster. |
No intermediate object code is generated, hence are memory efficient. |
Generates intermediate object code which further requires linking, hence requires more memory. |
Continues translating the program until the first error is met, in which case it stops. Hence debugging is easy. |
It generates the error message only after scanning the whole program. Hence debugging is comparatively hard. |
Programming language like Python, Ruby use interpreters. |
Programming language like C, C++ use compilers. |
Sunday, March 3, 2019
How to set Quota in Linux
Thursday, February 28, 2019
What is atime and noatime in fstab
Monday, February 18, 2019
SED Options
To Match Digit
sed -r 's/([^0-9]*([0-9]*)){2}.*/\2/' file
This extracts the second number:
sed -r 's/([^0-9]*([0-9]*)){1}.*/\2/' file
sed 's/[[:digit:]]\+\.//g'
$ echo "This is an example: 65 apples" | sed -r 's/^[^0-9]*([0-9]+).*/\1/'
65
59
Two problems:
sed does not support \d. Use [0-9] or [[:digit:]].
+ must be backslashed to get the special meaning: \+.
sed -r 's/.*_([0-9]*)\..*/\1/g'