Showing posts with label tips. Show all posts
Showing posts with label tips. Show all posts

Thursday, October 23, 2014

Show full list of program arguments in top command

Pass the -c argument to top to display the command line arguments that were passed to the process
top -c

Friday, January 13, 2012

Repeatedly run a command on Linux

The watch utility can be used to continuously run a command on Linux. For example in order to continuously monitor system memory via free the following command can be used:

watch -n1 free

Tuesday, December 21, 2010

Removing leading and trailing whitespace in C++

If you have the boost library installed, its simply a one liner

std::string line = "     hello world    ";
boost::algorithm::trim(line);


Thursday, April 8, 2010

Change lower case letters to upper case in bash

This can be done using the tr command.

For example:
echo "change my case" | tr '[a-z]' '[A-Z]'

Tuesday, March 23, 2010

Prepend string in bash using sed

You can do that using the following sed command


sed 's/^//g'

The key here is the use of ^ Which matches the start of line.

For example below is how you can prepend "foo" to a string "bar"


echo "bar" | sed 's/^/foo-/g'