Linux

Deleting Lines Containing Specific string from multiple files

Deleting Lines Containing Specific string from multiple files recursively Syntax: grep -Rl "STRING" /directory/path/ | xargs sed -i "/STRING/d" Example: Below example delete lines containing @license tag from src/main/php directory all files recursively grep -Rl "@license" src/main/php | xargs sed -i "/@license/d" Option Description: -R or --dereference-recursive For each directory…
More..

Get File MIME Type in Python

Get file MIME type in Python You can get mime type in python by using python-magic library. You can install python-magic using PIP. $ pip install python-magic To find mime type, import magic library and pass file path into () >>> import magic >>> ("path/", mime=True) 'application/pdf' If you face…
More..

Run Mysql Query from Command Line

Shell script to run mysql query from command line without login into mysql command prompt.  You can use these shell script for quickly execution of MySQL query from a Linux Shell. Method 1: #!/bin/bash #Script to run mysql query from command line #Db Connection. DB_USER='root' DB_PASSWD='mypwd' DB_NAME='mydb' #Prepare sql query QUERY='select *…
More..
TechieRoopSolution for DevOps & Open Source Technology2017