Posts Tagged With: space

Double space a file using Ruby

Tagged with: , , , , , ,

Double space a file with Ruby using the command


ruby -pe 'puts' < file.txt
No Comments »

Show Free RAM

Tagged with: , , , ,

This command shows the free RAM space in MB


free -m
No Comments »

Show Space Usage of a Directory

Tagged with: , , , , ,

Estimate space used by directory.


du -sh dir
No Comments »

Double Space a File using Sed

Tagged with: , , , , , , ,

Add a \n after every line in a file using the sed command…


sed G 
No Comments »

Python Function for Space Units

Tagged with: , , , ,

A Python function to return readable size using the given size(KB)


# Returns a more readable format of the given data. For example, getReadableSize(1024) returns "1 MB"
	def getReadableSize(size):
		unit = "KB"
		size = float(size)
		final = size

		if(size >= 1024):
			unit = "MB"
			final= "%.02f" % (size / 1024)
			size = (size / 1024)

			if(size >= 1024):
				unit = "GB"
				final= "%.02f" % (size / 1024)
				size = (size / 1024)

		return str(final) + " " + unit

[tags][/tags]

No Comments »