Category Archives: Linux

You got to love Linux. Not only that it is free, but it is also very strong, stable, and widely used.

Using grep as highlighter

1$ grep –color -E ‘^|pattern1|pattern2’ file name

Posted in Bash, Linux | Leave a comment

TCL programming

A reusable expect dispatcher I kept around for running the same kind of operation across a list of servers — untar an index, restart a service, patch a config file. The trick is that the script reads the first command-line … Continue reading

Posted in Linux, TCL/Expect | Leave a comment

Simple unit test is bash file

Consider the following 3 files: 1. shellTestFramework.sh 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#!/bin/bash # Copyright (c) Ronald Pringadi # Before each Test function setUpTest(){     #"Please overwrite this function on your unit test. Something that need to be done before each test"     … Continue reading

Posted in Bash | Leave a comment

Compare File Permission Recussively on Linux Directories

Scan 12345678910111213141516171819202122#!/usr/bin/perl use File::Find; my $directory1 = ‘/root/rpmbuild/RPMSX’; my $directory2 = ‘/root/rpmbuild/RPMSX.bak’; find(\&hashfiles, $directory1); sub hashfiles {   my $file1 = $File::Find::name;   (my $file2 = $file1) =~ s/^$directory1/$directory2/;         return(0) if (! -f $file2) ;   … Continue reading

Posted in Linux | Leave a comment

Linux find files and total their size

1find ./ -type f -newerct "1 May 2015" ! -newerct "1 Jul 2015" -print0 | du –files0-from=- -hc| tail -n1

Posted in Bash, Linux | Leave a comment

Wireshark filters

Filter by ip dst or source using wildcard on the last 3 digits: (ip.dst == 192.168.0.0/24) || (ip.src == 192.168.0.0/24)

Posted in Linux | Leave a comment

Allowing a linux/unix user all sudo access without password

/etc/sudoers yourusername ALL=(ALL) NOPASSWD:ALL

Posted in Linux | Tagged , | Leave a comment

Find with xargs

Search all files under current directory, look for xml node ‘‘, copy and print that node. Send the output to a file. find . |xargs -n1 xmlstarlet sel -t -c “//processorInfo[@ruleType=’store’]” 2>/dev/null > /cygdrive/b/allstore.txt

Posted in Linux | Leave a comment

XMLStartlet – Command line xml queries

xmlstarlet sel -t -c “//YOUR_NODE_ELEMENT_TAG_NAME[@ATTRIBUTE_NAME=’ATTRIBUTE_VALUE’]” YOUR_XML_FILE.xml

Posted in Linux | Leave a comment

Bash Scripting templates

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859# ========================== # Bash tips # ========================== # Run bash by $ /bin/bash scriptname.sh $ /bin/bash scriptname.sh +x  # debug mode # Or put the next line on the 1st line of your file. #!/bin/bash -x ## Double round braket … Continue reading

Posted in Linux | Leave a comment