Thanks for the links i will check it out! Also i wasn't aware of the -F function, playing with it now and that is a big help with working around the whole color bit. Clearly the / is for directories. How are the rest used? Surprisingly even google doesn't know. From what i could see they didn't label links and such so not very helpful in that respect but at least i wont try to vi a directory or cd to a file.
On Mon, Oct 3, 2016 at 7:43 PM, Evan Gates <evan.ga...@gmail.com> wrote: > On Mon, Oct 3, 2016 at 4:34 PM, stephen Turner > <stephen.n.tur...@gmail.com> wrote: >> @Evan >> I am not too fluent at advanced shell at the moment so help me out >> with this one please, I checked the advanced scripting guide but want >> to make sure i understand this. > > Please do not read that, it's full of practices that are outdated and > in many cases it is plane wrong. Instead check out the bash guide[0] > and the accompanying bash faq[1] and bash pitfalls[2]. Although the > wiki is bash specific it also covers POSIX sh very well. > >> s() { ls -F "$@" | cols; } >> s() implies that you have created an alias for ls as "s" and the () is >> to listen for what follows for the flags "-h etc"? > > It's a function definition. > >> {} is to encapsulate the real commands, > > The body of a function is a compound command, meaning it's one of: > a list in braces > a list in parens > a loop (for, while until) > an if statement (with following elif, else) > a case statement > > That said most often you'll see braces. > >> ls -F "$@" the "$@" is to pass along the flags from s()? > > "$@" expands to the positional parameters (arguments) and must be > quoted otherwise you can run into further word splitting and glob > expansion (this is true for all expansions/substitutions). > >> and for the ; at the end of cols, i assume this terminates in a way >> that prevents it from grabbing further input? > > A terminator is needed before the closing brace, both newline and > semicolon are accepted. > > [0] http://mywiki.wooledge.org/BashGuide > [1] http://mywiki.wooledge.org/BashFAQ > [2] http://mywiki.wooledge.org/BashPitfalls >