[console] shell discovery - HI Help a noob!

im trying to do tutorial with my friend

i need to “answer something” for “certain names” in bash shell


Sorry to write here but its the only place i know, is there a good place to learn these things? i tried discord but i could not write there, sorry im super noob, i dont have any studies or experience ( know how to make folder or copy file on konsole ) i really like it !

Hi @h0rr,

Well, you don’t show us the question, so we can only guess.

Regardless, don’t have other people give you answers to questions. Rather, go look for them yourself. There’s a whole internet to help you, if, and only if you look for things yourself, try them, test them, and learn (from) them.

Have a look here:

Also here:


Start with these two resources:

  1. To learn the shell and bash (book or online): Linux Command Line Books by William Shotts
  2. To get an overview of linux (self-paced course): Introduction to Linux (LFS101x) - Linux Foundation - Training

In addition:

  1. Read the arch wiki as needed: https://wiki.archlinux.org/
  2. Bash FAQ, in the form of question/answer: https://mywiki.wooledge.org/BashFAQ
  3. Although specific to other distro’s, these magazines have beginner-friendly articles

Everything in Linux is documented in man pages, so you can man bash at the command line. Some documentation can be found in “/usr/share/doc/package”. Replace package with bash. This documentation may be the same as the man page, but in a different format. There are many sites that host man pages, here’s Arch Linux man pages.

If you query a package like, pacman -Qi bash, you will find the URL or home of the package. In this case, Bash - GNU Project - Free Software Foundation. You will find more documentation at a package home.

youtube is your friend. Old Tech Bloke is well done and covers various aspects of distros so you can learn the lingo in context, but you can also find videos on specific topics.

I see you are using KDE (the mention of konsole). To stay current on KDE subscribe to: This Week in KDE – Adventures in Linux and KDE.

1 Like

thanks so much!!

the question was:


Two-fer or 2-fer is short for two for one. One for you and one for me.

Given a name, return a string with the message:

One for name, one for me.

Where “name” is the given name.

However, if the name is missing, return the string:

One for you, one for me.

Here are some examples:

Name String to return
Alice One for Alice, one for me.
Bob One for Bob, one for me.
Me/Self One for you, one for me.
Zaphod One for Zaphod, one for me.

declare -- name=''

while read -r name; do
  if [[ -z "${name}" ]]; then
  printf -- 'One for %s, one for me\n' "${name}"
done <<EOF


The control structure could also have been

for name in 'Alice' 'Bob' '' 'Zaphold'; do

Some take aways:

  • quoting
    • double
    • single
  • printf instead of echo
    • -- after printf
  • [[ ]] instead of [ ]
  • the test operator -z
    • type help test to view more

On the command line you can get short help for bash, like: help if, help for, help printf.

When you want to learn more about a command, type -a. Try type -a [ and type -a [[. Notice one says shell keyword and the other shell builtin. Also type -a : .

Definitely look the above items up in the bash man page/documentation to learn more.

Search the internet for style guide or best practices. Here is google’s: styleguide | Style guides for Google-originated open-source projects. Last, whatever you do, be consistent and comment # and document :slight_smile:

PS: Regarding formating, I use code blocks to retain spaces:


thank you so much!!!
true master!!! :slight_smile:

or, in this example : [[ -z "${name}" ]] && name="YOU" or name="${name:-YOU}" (less for beginners)

I was trying to be a little bit verbose, to cover more topics. Good one. I love bash parameter expansion :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.