Page 1 of 1
coreutils
Posted: Thu Dec 31, 2015 2:59 pm
by machinebacon
We have a Shell Tips & Tricks section which actually covers the builtins of your shell. This section here shows the power of coreutils:
Code: Select all
[ arch base64 basename cat chcon chgrp chmod chown chroot cksum comm
coreutils cp csplit cut date dd df dir dircolors dirname du echo env
expand expr factor false fmt fold groups head hostid hostname id install
join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl
nohup nproc numfmt od paste pathchk pinky pr printenv printf ptx pwd
readlink realpath rm rmdir runcon seq sha1sum sha224sum sha256sum sha384sum
sha512sum shred shuf sleep sort split stat stdbuf stty sum sync tac tail
tee test timeout touch tr true truncate tsort tty uname unexpand uniq
unlink uptime users vdir wc who whoami yes
So let's see if we can collect some tips & tricks here, too.
Re: coreutils
Posted: Thu Dec 31, 2015 3:03 pm
by machinebacon
Code: Select all
_
___ __ _| |_
/ __/ _` | __|
| (_| (_| | |_
\___\__,_|\__|
Merge multiple MP3 to one
Heck, there are programs like
mp3wrap or
sox, but the best and fastest merging tool for mp3s (or any other audio files) is already there in coreutils. This probably does not work if the bitrates are changing.
Code: Select all
cat song_1.mp3 song_2.mp3 song_3.mp3 song_4.mp3 > side_a.mp3
Bonus tip: if you want to create a slideshow for youtube (so, music and an image), ffmpeg can do that for you:
Code: Select all
ffmpeg -loop 1 -i image.jpg -i side_a.mp3 -c:v libx264 -c:a copy -strict experimental -shortest slideshow.mp4
Create live USB from ISO
This replaces tools like
dd. Useful if you want to put an ISO on a device
Code: Select all
cat linuxbbq_anorexicteen.iso /dev/sdb
Live heredoc
This replaces the
touch command. If there is no busybox vi or nano available (lol), you can use cat to create files. It takes stdin until you press Ctrl-d
Line Numbering
Nothing special, some people like to have line numbering because they use ed to edit files (lol, NOT!)
Re: coreutils
Posted: Thu Dec 31, 2015 3:40 pm
by dkeg
Wow. First, I'm surpirsed we have not yet made this thread. Second, I use coreutils everyday, well, at least I thought I was.
What comes first, a need, thus searching and finding a solution which uses a command that we all use often, OR, learning new ways to use a command we use almost daily and looking for use cases to try it out.
Re: coreutils
Posted: Thu Dec 31, 2015 5:44 pm
by rhowaldt
what drew said. also, some really cool things with cat. did not know it could replace dd. why is there no tool called dog, and if there was what would it do?
here's another cool thing you can do with cat:
awesome. some more useless stuff
here.
sorry i don't have any proper tricks :)
Re: coreutils
Posted: Sat Jan 02, 2016 8:19 pm
by ChefIronBelly
Re: coreutils
Posted: Sun Jan 03, 2016 12:45 pm
by wuxmedia
'bout the only one I can think of and use daily:
Code: Select all
mv public_html hacked_public_html_`date -I`
Most people use
which frankly I still can't recall.
(it appends a nice full ISO date, 2016-01-03)
or using cat at work:
Code: Select all
cat big_data.sql | mysql -u root -p big_data
Re: coreutils
Posted: Mon Jan 04, 2016 7:08 pm
by doubledutch
I'm quite fond of the command:
What day does Christmas fall on, this year?
Re: coreutils
Posted: Mon Jan 04, 2016 9:31 pm
by ivanovnegro
I think we always use cat to see what our sources list looks like:
When playing with files I often use the rm command:
wipes the file and:
wipes an entire directory.
But you already know this. ;) coreutils is such a powerful tool in general.
Re: coreutils
Posted: Tue Jan 05, 2016 6:26 am
by machinebacon
shows a summary of local disk usage in human readable format
Code: Select all
du -sh ~/.local/share/
du -sh ~/README
shows the disk usage of the directory (or file) in human readable format
you don't really need 'diff' because 'comm' can do the same, basically
head shows the first
n lines of a file, in our case we will know what default runlevel we boot to by default
this follows changes at the end of a certain file, in our case the kernel ring buffer (we know this from syslog and dmesg, which is part of util-linux)
Code: Select all
paste FILE1.txt FILE2.txt > FILE_ALL.txt
pastes the content two files, line by line. it is not the same as using cat which pastes file after file.
probably useful for databases if you change the delimiter (-d), eg. for CSV