Posts

Showing posts from March, 2016

apt to yum - Cheat sheet - Conversion

apt-get install yum install apt-get upgrade yum upgrade apt-get remove yum remove apt-get --reinstall install yum reinstall apt-get install foo=1.0 (to downgrade to version 1.0) yum downgrade foo-1.0 apt-get clean yum clean apt-get build-dep yum-builddep dpkg -l yum list installed apt-cache search yum search apt-cache search --names-only yum list repoquery dpkg -L rpm -ql apt-file list repoquery -l   Difficult - not commonly known conversions  apt-cache show yum info repoquery -i apt-get purge yum remove apt-get dist-upgrade yum upgrade yum distro-sync apt-get source yumdownloader --source dpkg --get-selections yum-debug-dump dpkg --set-selections yum-debug-restore dpkg -S repoquery --installed -f rpm -qf apt-file search repoquery -f yum provides rpm -qf apt-get --simulate upgrade yum check-update yum --assumeno upgrade apt-get --simulate install yum --assumeno install sbuild

How to commit a large chunk of modified files in svn.

Recently while working on a project controlled with svn, I had modified a lot of files and had to check them in. Now being a lazy person, I didnt wanted to send files one after the other. Thus, on Googling came across this wonderful method that uses a target file to commit a large chunk of files. So Let's check the environment by typing the command : - Note you can use directly the second command and skip this one. >>  svn stat | grep ^M | tee modified.log This command - check for the status of files which are modified. (svn stat | grep ^M) Adds the output to a file tee modified.log. >> svn stat | grep ^M | cut -c 8- > modified.log This will overwrite the previously created file. To checkin the files type the following command >> svn ci -m "Message you wish to pass" --targets modified.log Hope you will enjoy this post. :)

How to loop over specific files in python.

Hi all, Generally we wish to loop over specific category of files in python. So how do we do this. Method 1 : - Using glob import glob , os os . chdir ( "/mydir" ) for file in glob . glob ( "*.txt" ): print ( file )   Method 2 :- Without glob import os for file in os . listdir ( "/mydir" ): if file . endswith ( ".txt" ): print ( file ) Method 3 :- Using Os.walk import os for root , dirs , files in os . walk ( "/mydir" ): for file in files : if file . endswith ( ".txt" ): print ( os . path . join ( root , file )) Original source : - https://stackoverflow.com/questions/3964681/find-all-files-in-directory-with-extension-txt-in-python

Convert rows into space-delimited line and vice versa

While dealing with text processing jobs we would like to convert a selection of rows separated by \n and convert it to space delimited single line.  We will do this with 'tr' - unix tool that translates, deletes, squeezes characters from standard input and writes the same to standard output. "Awk" is a powerful tool used to perform pattern scannind and processing language and it is one of the important commands, a powerful linux user should be aware of its usage.   To convert rows into a space-delimited line and save to a file : $ cat intput.txt ankit shah is my name I am awesome $ cat input.txt | tr "\n" " " | tee output.log ankit shah is my name I am awesome To convert spaces to line break (newline) and save to a file : $ cat intput.txt Hi how are you doing sed -e 's/\s\+/\n/g' input.txt | tee output.txt Hi how are you doing

Find email id of any github user.

Hi all, Recently, while browsing github, I wanted to find email id of a github user and imagined if there is a possible way to find this person as I am interested in learning more about the work on his github account and would like to contribute to the same. Luckily I found that the github api is very insecure and presents the email id of a github user with ease. So, here's a script that will help you determine email id of any github user. ============================================ #The script for finding email address of any user. function _md5() {   if which md5sum > /dev/null; then     echo -n $1 | md5sum | cut -d " " -f1   else     md5 -q -s $1   fi } USAGE="$(basename "$0") [-e] [-g] user -- Find the email address of any GitHub user Where:     -h, --help Help: display this help message     -e Event log: show all emails that appear in the user's event log     -g Gravatar match: attempt to match an event email to the user