Recently I needed to recursively count the number of lines of code in each of the specific file types. In this instance I wanted to count the number of lines of code in my PHP files. The below command worked flawlessly. In addition to breaking down the line count in each directory, it gives a overall total at the end as well.
pv – Pipe Viewer – is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion.
I found a handy technique to find files modified between a specific date. In essence, we touch two temp files, setting the modified dates to the range we want to find:
Note the date is yyymmddtime.
Then we run the find command:
The following command will search for a string within files in a directory recursively.
sudo find . -type f -print0 | xargs -0 grep -n 'STRING TO SEARCH FOR'
Ok this is sweet:
ssh firstname.lastname@example.org “cat /Torrents/Complete/15\ years\ of\ Essential\ Mix\ Sasha\ \&\ Digweed/Essential\ Mix\ 137\ -\ Sasha\ -\ Live\ @\ radio\ 1\ on\ tour\ from\ Sanctuary\ -\ [30.06.1996].mp3” | mpg123 –
And here is a more advanced version to find multiple files (unworking)
ssh email@example.com “find /Torrents/Complete -wholename \*Essential\*.mp3 -print0 | xargs -0 cat” | mpg123 –
this finds fines in /Torrents/Complete and pipes them to mpg123
One of my clients needs their vendor to be alerted when their Backup Exec service crashes. I wrote the following quick-n-dirty batch script intended to be ran as a cron job.
And the cron line would be something like this: