scan your network with bash IP scan script
Here is the youtbe video that will walk you through bash script.
Here is the youtbe video that will walk you through bash script.
I have been thinking of posting this for sometime now. This is very useful, when you are working on a different Linux box and want to upload a file to dropbox.
So, before you run this command, you need to create your auth token in Dropbox developer API page. Once that is done, need to change the 2 parameters in command below. Export your Access token and run the below command.
Continue readingI generallly keep doing this a lot, so thought will share with you. Lets assume we are capturing free ouput every min/hour/or whatever. The output looks like this:
Time: Mon Jan 21 23:59:10 AEDT 2019
——————-total used free shared buff/cache available
Mem: 32014 8656 1735 1697 21621 21308
Swap: 51195 75 51120
then we can use some grep and sed to convert this to something like this:
Mon Jan 21 23:59:10 AEDT 2019,32014,8656,1735,1697,21621,21308
Continue reading
Sometimes some simple one-liner function can save you a lot of time, like-
wps ()
{
rpm -q --whatprovides $(which $1 )
} # ---------- end of function wps ----------
Lot of times, I want to find the directories with maximum number of files and so I wrote this quick function to do exactly the same
function count_lines ()
{
oldIFS=$IFS
count=0
IFS=$'\n'
dir=${1:-.}
cd $dir
find . -type d |while read line
do
echo -n "$(find $line -type f |wc -l) $line"
echo
printf "Directories :: %8d\r" $count >&2
((count++))
done|sort -n
IFS=$oldIFS
} # ---------- end of function count_lines ----------
When moving large files/directories, I would like to see the progress.
Idea for this is to use rsync with progress and remove source files. But that option does not remove the empty directories left behind so find command to delete that.
So, here is function for that:
mv-progress ()
{
rsync -ah --progress --remove-source-files "$1" "$2";
find "$1" -empty -delete
}
I find myself doing this lot of times so thought will share this with you all. Basically, once I want to clear out the directory, I first want to find out the sub-directory using the maximum disk space so I wrote a function for that and here it is:
disk_usage_dirs ()
{
find . -maxdepth 1 -type d -not -name '.' | while read line; do
du -s "$line";
done | sort -n | tail -${1:-5}
}
Some other posts you might find useful on this :
Continue reading