hazard
Bash Function | Linux and Photography Blog Skip to main content

Linux and Photography Blog

  • Contact Form
  • Privacy Policy

Tag: bash function

bash function for rpm whatprovides

December 31, 2018January 30, 2019 Amit Agarwal Leave a comment

Sometimes some simple one-liner function can save you a lot of time, like-

wps ()
{
    rpm -q --whatprovides $(which $1 )
}   # ----------  end of function wps  ----------

Link to this post!

Socialize

mv command with progress

March 19, 2018March 11, 2018 Amit Agarwal Leave a comment

When moving large files/directories, I would like to see the progress.

Idea for this is to use rsync with progress and remove source files. But that option does not remove the empty directories left behind so find command to delete that.

So, here is function for that:

mv-progress () 
{ 
    rsync -ah --progress --remove-source-files "$1" "$2";
    find "$1" -empty -delete
}
Link to this post!

Socialize

Highest disk usage of directory in subdirectories

March 12, 2018March 11, 2018 Amit Agarwal Leave a comment

I find myself doing this lot of times so thought will share this with you all. Basically, once I want to clear out the directory, I first want to find out the sub-directory using the maximum disk space so I wrote a function for that and here it is:

 

disk_usage_dirs () 
{ 
    find . -maxdepth 1 -type d -not -name '.' | while read line; do
        du -s "$line";
    done | sort -n | tail -${1:-5}
}

Some other posts you might find useful on this :

Disk usage by file type

Color disk usage on Fedora

Get disk usage for all the containers with python script

Link to this post!

Socialize

Posts navigation

1 2 Older posts

Search

Pages

  • Contact Form
  • Privacy Policy
  • Sitemap

Blog

  • Android App
  • Contact Me
  • G+ Profile
  • Homepage
  • Login
  • My Photo Gallery
  • My Photos
  • RSS Feed

Cal

December 2019
M T W T F S S
« Oct    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Email Subscribe

Myself

raj77in

raj77in

Linux and Photography is my passion. Blog: http://blog.amit-agarwal.co.in

Personal Links

  • Linux Blog
  • Linux and Photography Blog
  • Docker Hub
  • Github

Verified Services

View Full Profile →

sparkling Theme by Colorlib Powered by WordPress