Computer Section - Main Page :: Linux Section - Main Page

Command Line - One Liners

The beauty of Linux is the fact that the console is such an integral part of the system. Many may look upon using the console as going back to the bad old days of DOS but Linux BASH and other command line programs are programming languages in their own right, as such, and are powerful tools to ENHANCE the computer experience and the user's control of the computer.

This page is not really for learners as I would need much more than 1 line to explain each command. There are other pages in the scripts section which explains the commands being used within those scripts.


Substitute hex characters, changing all uppercase 'A' to lowercase 'a'

sed -i 's/\x41/\x61/g' text-file

Convert text file from DOS to Linux (line endings)

sed -i 's/\x0d$//' text-file

Convert text file from Linux to DOS (line endings)

sed -i 's/$/\x0d/' text-file

Take all spaces out of all file names (NOT sub-directory names) within the current directory

for x in *; do if [ -f "$x" ]; then y=$(echo "$x"|sed 's/ //g'); mv -T "$x" $y; fi; done

Take all spaces out of all file names (and sub-directory names) within the current directory

for x in *; do y=$(echo "$x"|sed 's/ //g'); mv -T "$x" $y; done

create a function, in ~/.bash_aliases to do the same:

function my-spc2b {
   for x in *; do y=$(echo "$x"|sed 's/ //g'); mv -T "$x" $y; done
}

Substitute all spaces with hyphens for all file names (and directory names) within the current directory

for x in *; do y=$(echo "$x"|sed 's/ /-/g'); mv -T "$x" $y; done

create a function, in ~/.bash_aliases to do the same:

function my-spc2h {
   for x in *; do y=$(echo "$x"|sed 's/ /-/g'); mv -T "$x" $y; done
}

Top of Page


List all files in the long list format. This function is put in the ~/.bash_aliases file. it allows the use of wildcards - in quotes.

function lsf {
   case $# in
      1 )    ls -l $1 | sed -n '/^-/p' ;;
      * )    ls -la | sed -n '/^-/p' ;;
   esac
}

How to rip tracks from more than a 1 CD and join them to form 1 (long) mp3 file

I am hooked on Wagner. In many cases a single Act of his operas is usually spread over 2 CDs. The way to end up with just one mp3 for each Act is simple enough.

For this example, I will take the Tristan und Isolde opera - Act 1. It comprises of all the tracks on CD1 and tracks 1-7 on CD2. So first, we rip the tracks, using cdparanoia, 1- (from track 1 to the end) on the first CD, and then rip the tracks 1-7 on the 2nd CD. It actually doesn't matter what you call the wav files - they will be discarded after encoding as an mp3 file.

Then join the 2 wav files using sox (sox file-p1.wav file-p2.wav full-file.wav). Then use lame to encode the new full Act wav file as 1 mp3 file. I encode as variable bit rate with the maximum set at 128bps Then use any mp3 player to insert the tags.

cdparanoia -w 1- act1-1.wav      # all of CD 1
cdparanoia -w 1-7 act1-2.wav     # 1-7 tracks of CD 2
sox act1-1.wav act1-2.wav Act1.wav
lame -v -B 128 Act1.wav Wagner-Tristan-und-Isolde-Act1.mp3


Updated: 15th April 2012

DISCLAIMER OF WARRANTY

The advice, scripts, commands, and examples contained within this web-site are provided "as is" and without warranties of any kind whether express or implied. In no event shall the author be held liable for any damages whatsoever, including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other loss arising from the use or inability to use, or malfunctions of, the software, the scripts, the advice, or the one-liners.

Neither will I accept responsibility for global warming, terrorism, the two world wars, pot holes on my road - well maybe, injustice in the world, USA torture and bullying, or the madness of King George or the other mad George (W Bush). I also will not accept responsibility for the beating of a butterfly's wings in the rain forests of South America, the Wall Street crash in 1929, the fall of the Roman Empire, or the stupid dumb-ass reality tv programmes aimed at the plebian mentally retarded brain-dead idiot generation of the 21st century.

In fact it looks as if I am not taking any responsibility for anything - does that make me totally irresponsible??!!"

Coding and design by Lou Gogan.   Any problems with this page? Please let me know.

Copyright © 2002-2016 Lou Gogan   All rights reserved.

The contents of these web pages along with all the images, sound files etc on this web site were created by and belong to Lou Gogan and are not to be reproduced or distributed in any way whatsoever, without written permission (political section has exceptions). You do have permission to take a copy for your own private and personal - NON commercial use.


Go To Top of Page