Create a python script $ more memReport.py #!/usr/bin/python import subprocess import re # Get process info ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0].decode() vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[0].decode() # Iterate processes processLines = ps.split('\n') sep = re.compile('[\s]+') rssTotal = 0 # kB for row in range(1,len(processLines)): rowText = processLines[row].strip() rowElements = sep.split(rowText) try: rss = float(rowElements[0]) * 1024 except: rss = 0 # ignore...

Read More
cli

Let’s take an plain text file, input.txt, that looks like this PATTERN-1 First line of unimportant text Second line of unimportant text PATTERN-2 Some more texts (may/ mayn't be important!) We want to delete some of the lines from the file using the command line stream editor, sed. 1. Use the following command to delete the lines lying between PATTERN-1 and PATTERN-2 , excluding the lines containing these patterns: sed '/PATTERN-1/,/PATTERN-2/{//!d}' input.txt If you...

Read More
cli

Here are two ways to delete the blank lines in a text file opened with vim: 1. Delete all the blank lines with NO white spaces other than new lines: :g/^$/d 2. Delete the blank lines containing any type of white spaces: :g/^\s*$/d BONUS: Remove only multi blank lines (reduce them to a single blank line) and leaving single blank lines intact: :g/^\_$\n\_^$/d Reference: Stack Overflow....

Read More