Just a nice post with a some nice examples about how to use brace expansion in bash. Assuming you use the shell and bash script to automate your tasks this is a nice reference.
Just a nice post with a some nice examples about how to use brace expansion in bash. Assuming you use the shell and bash script to automate your tasks this is a nice reference.
Give it a try, for $1 dollar you get 5 books, for $8 dollars you get 7 books more, and for $15 dollars you get 16 books in PDF, mobi or ebook. They can also email them to your kindle ;-). Did I mentioned they are DRM free? ?
Get a bundle of Unix ebooks and support charity!
Source: Humble Book Bundle: Unix presented by O’Reilly (pay what you want and help charity)
PowerShell, the shell that Microsoft Windows uses (don’t confuse it with the command line, PowerShell is way more powerfull than that) is now Open Source, note Open Source, not Free Software. Why does Microsoft opened its Shell?.
Well, I suppose that marketing team got a hit with the “Microsoft ❤️ Linux” slogan, but the true is that no, Microsoft does not Love Linux.
Microsoft has changed a lot, but is not just because Microsoft suddenly wanted to be the good guy. Please remember how is that Microsoft become one of the most popular software companies in the world. Without taking credits of being a doer. Bill Gates bought DOS to a company, modified it and resold it as MS-DOS, that gave it the chance to surpass the others since Microsoft was not tied to a computer vendor. They needed an OS.
wget -O - http://islascruz.org | \ grep -o '<a href=['"'"'"][^"'"'"']*['"'"'"]' | \ sed -e 's/^<a href=["'"'"']//' -e 's/["'"'"']$//'
What can I say?, Microsoft finally accepted that they needed it to be “serious” about servers. I personally hope I won’t ever have to deal with using a server running Windows, not even if it runs bash, although if it is done fine the common “usage” for the user will be fine. I think the problems will come with the underlying platform, I mean Windows by itself, the kernel, the system calls, and the way it handle processes etc..
The surprise… Canonical, the fucking SOLD to Microsoft. My conspiranoic side already had these ideas that Ubuntu and its “convergence” stuff were nothing but the playground to what now is Microsoft Windows 10 Continuum, the scopes, and everything else might be that thing too.
Canonical working with Microsoft is nothing new, they have been working with Microsoft for years to make Ubuntu run as smooth as possible in the Azure framework. But I really think that Canonical is giving itself a shoot in the foot by making Bash to work nice in Windows.
I don’t expect it to run as good as it already does in Linux, bash is good but bash is a shell with a subset of commands (and other programs) but is not Linux.
So, I have a bunch of ogg files that I moved to mp3 (I don’t want to start a format/encoder war, I just did it), I wanted to move the old ogg files, I didn’t delete them because probably I need them in the future. To move the files apart the easiest way could be using find and xargs:
find . -iname "*ogg" -print0 |xargs -0 -I {} mv {} /dest/folder/
The problem with this is that all those ogg files would be in /dest/folder/ all together, and I want to have them each in the corresponding subfolder, I was looking and found that some uses “cp –parents” unfortunately it seems that the cp in OS X does not include that.
If you create a package file (.tar for example), the directories are preserved, so, for me the trick was using tar for that purpose.
find . -name "*ogg" -print0 | xargs -0 tar cvf - |(cd /dest/folder/ ; tar xfp -)
You’ll see all those ogg files in the screen as they are “copied” to the destination folder. later you can remove the files with find again.
find . -iname "*ogg" -delete
I assume there is a way to remove the files as soon as they have been added to the tar file.
find is a great tool to find things, but not only to find them, but to work on them. I have a small collection of music, which I presume at some point will be removed from my computer hard drive (maybe if I can get a new one it won’t be there at all) because I mostly listen to music from internet and I have a copy of the music in a external hard drive.
Today I imported the folder where the music is to iTunes again, and it created playlists that I don’t remember to have them before. That is because there were several m3u files there (winamp playlists), there are around 5k files in that directory tree and I don’t want to spend my time looking for m3u files, so, let the computer do the job.
With find is easy to find files, not by their name but by their type the f is for file.
find . -type f
Ok, but that will include all the “mp3” which are files, so if I make use of -iname to find by name, how can I do the opposite?, well, like in most programming languages, you can negate by using the exclamation symbol !.
find . -type f ! -iname "*mp3"
And add some more extensions.
find . -type f ! -iname "*mp3" ! -iname "*ogg" ! -iname "*m4a" ! -iname "*wma"
That will give me all files that are not mp3, ogg, m4a or wma. Then just use the -delete parameter to as find to delete them.
find . -type f ! -iname "*mp3" ! -iname "*ogg" ! -iname "*m4a" ! -iname "*wma" -delete
And… they are gone.
How would you do it?. Share it in the comments.