Remove downloaded archive files from apt-get
Answer:
To remove ownloaded archive files from apt-get to save spaces, try the following command:
# sudo apt-get clean
So all the unneeded archive files will be removed.
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
Remove downloaded archive files from apt-get
Answer:
To remove ownloaded archive files from apt-get to save spaces, try the following command:
# sudo apt-get clean
So all the unneeded archive files will be removed.
Generate a random number in Python
Answer:
It is very easy to generate a random number in Python, see below:
import random
print random.randint(1,100)
The above code print a number between 1 to 100.
How do I find and replace non-printable characters in vim?
Answer:
To replace non-printable characters in vim, e.g. get rid of ^M, you need to use the following replace method.
:%s/^M//g
Notes: The ^M above was inputted by holding down "Ctrl+v+m" at the same time.
Compress and decompress file using 7zip
Answer:
7zip is a well known compression program if you need a very small file size, i.e. high compression ratio.
To install under Ubuntu/Debian:
# sudo apt-get install p7zip
To compress a file
# p7zip test.txt
To decompress a file
# p7zip -d test.txt.7z
Multi-line string in Python
Answer:
In Python, multi-line string are enclosed in triple double (or single) quotes:
E.g.
s = """Line1
Line2
Line3"""
print s
Or
s = '''Line1
Line2
Line3'''
print s
Both methods are valid.