Bash/Linux – Folder Flattening Script (keep X number of subfolders)
A folder flattening script for your files. Takes files and folders in a location & makes the folder tree less deep (if files have same name it will rename a file so thatRead More…
A folder flattening script for your files. Takes files and folders in a location & makes the folder tree less deep (if files have same name it will rename a file so thatRead More…
1 2 |
# echo "thislinehas%allovertheplace%%asdf%%" | awk '{print $0}' thislinehas%allovertheplace%%asdf%% |
Really quick… the above and below commmand simply tells awk to print the inputed line, so that the output should look as if it was only the echo command that wasRead More…
Use this convertbytes2human function, If you want to convert a number of bytes (for example 43252) or an exponential number number of bytes (such as 1.03e5) to a human readable size. NOTE: sinceRead More…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# Awk is missing ABS - absolute value - so we have to make it. # if you want to do: y=abs(x) # you cant just write the above as abs(x) is a missing function. You have two options (and many more after that) #------------------------------------------# # option1: make a quick abs replacement y=(x<0?-x:x) # it checks if x is negative with x<0 and if it is, it converts it to positive with -x, if x is already positive it just remains as x # option2: make the abs function function abs(value) { return (value<0?-value:value); } # or as a oneliner it would look like this: function abs(value){return (value<0?-value:value);}; #------------------------------------------# # examples of use of option1: echo -50 | awk '{x=$1;y=(x<0?-x:x);print y}' echo 150 | awk '{y=($1<0?-$1:$1);print y}' # examples of use of option2: echo -50 | awk 'function abs(value){return (value<0?-value:value);}; {x=$1;y=abs(x);print y;}' echo 150 | awk 'function abs(value){return (value<0?-value:value);}; {print abs($1);}' |
This will convert a second into a more feasible number split up into parts of hrs/min/sec (or if you want also days and weeks and years) Provided 5 configurations of this converterRead More…
Solaris “ifconfig” and “ifconfig -a” miss out on interesting values like “error” & “drop” etc. netstat and ndd are its replacement in that case
1 2 |
# see common stats - usually seen with "ifconfig -a" in linux netstat -i |
Find out your interface names in /devRead More…