This is not intended to be a complete programming introduction, it was meant to help people solve a problem they might have. As for the preceding "./" I did not want to be confusing people this early in the game ( "./" and "/" would look a bit too similar to me, at a glance, if I were a beginner). I had to be obvious because I wanted to be as concise as possible, as it was long-winded enough.

True enough

Quote:

Honestly, I do not have a single problem with using ls in a command substitution. In fact, I have more problem with the inclusion of spaces and newlines in filenames, as, I feel, that is more against naming convention. When it comes to naming files, I like to treat spaces and newlines as illegal characters myself. Instead I use CamelNotation and dashes.

The reason not to use "ls" is because it wont have "inclusion of spaces and newlines in filenames". Also it looks more simple without the ls.
The quotes are necessary for inclusion of newlines/tabs/spaces.

So in order for the script to adapt to the filename and not the other way, it is better to have quote and not use ls.

I did not know you could leave the ls command out of the for loop and achieve the same result (I just checked that out and was surprised). Nice shortcut there, thanks.

With my Roxapp example, the script only deals with files that are essential to the program itself. Data files are handled from within the program. The script only sets up the program temporarily and cleans itself up when you are done using it.

As for quoted variables, they have always looked wrong to me... probably because of my earlier experiences, but it is nice to know that quoting a variable allows it to handle data containing spaces. I was wondering how to go about doing that. I don't like putting spaces in filenames and I know many coders don't either, but I guess I have to know how to deal with them if I'm going to code.

some of the biggest commands I have trouble with are grep, sed, and awk. I also have trouble with regular expressions (or at least, complex ones.... kinda like Algebra ). That's when it really starts to get confusing to me. I try to avoid those wherever I can.

@rj: I placed this in beginners because I wanted to let people know that, yes, even a beginner can learn to use the CLI. I'm sure there are beginners who are interested in this kind of stuff but may not be quite ready to leave the beginner's circle yet. This can ease them into a more advanced area.Last edited by PupGeek on Sun 06 Mar 2011, 18:37; edited 1 time in total

Joined: 18 May 2005Posts: 11132Location: The Peoples Republic of California

Posted: Mon 07 Mar 2011, 02:52 Post subject:

Why use the command line.

In the beginning was the command line. I couldn't build or setup a
computer without using the command line. Today, maybe I could, but
I've not tried it.

The primary reason I use it so extensively today is because it is so much
faster and easier than the GUI in many cases.

In and of itself, I don't think the command line would be faster,
except for the aliases and scripts we make.

Additionally, when the computer doesn't work right, there often isn't a
GUI application to do the troubleshooting and repair. The power user
knows what command line tools are available and how to use them.

Presently, as I write this text, I'm converting .wav files to .mp3 files in
large batch. There is probably a GUI tool to do this. Even if there is, it
won't provide me with the level of control I can get with my own script.

I might have almost one terabyte of data on my computer. Because of
scripts I've written, I can find files much faster than the computer can
search itself with any GUI tool I know of.

Another useful command is "mkdir -p"
mkdir= Make directory
-p = Make the parent file if it doesn't exist.

So, i want to make a directory /mnt/sda1/lupu52/backup/2010

Code:

mkdir -p /mnt/sda1/lupu52/backup/2010

Instead of making a dir, enter it, make another dir, enter it.

Also, if you keep making some minor typo when doing "cd"

Code:

shopt -s cdspell

This will auto correct some of your mistakes while doing "cd"
----
EDIT
Also, i dunno what the "shift" is for. It is redundant
I just thought that i will copy it over... Last edited by r1tz on Mon 07 Mar 2011, 05:56; edited 1 time in total

When done, delete the file r, it's purpose is served
and I will show you a much better way.

~

Bruce, would you be sharing how to do it in a better way? .
I find this thread useful, I didn't know the "help" command exist - I keep referring to the bash reference manual when I need to know how a certain internal command works._________________Fatdog64, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread.

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum