Giter Site home page Giter Site logo

bash-guide's People

Contributors

arfrhmd avatar aubree avatar behitek avatar borekb avatar cary-williams avatar codebrauer avatar derek52 avatar diegosanz avatar diserere avatar evanhahn avatar floj avatar ganes1410 avatar gibatronic avatar idnan avatar itsashis4u avatar joaofreires avatar juremalovrh avatar kamranahmedse avatar kaveet avatar klikstermkd avatar lex111 avatar mariotristan avatar masoud-maghsoudi avatar mumararshaikh avatar ohmyhusky avatar omergulen avatar patrickskovgaard avatar sebring avatar vuuihc avatar zelazna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bash-guide's Issues

quoting rules

quoting rules really need to be addressed

specifically:

  • double quotes perform string interpolation
  • never use variables without double quotes

first for loop example does not work

First of all, thanks for the amazing bash summary!
I think I found a problem with the first for loop example.
It is not working as intended:

for x := 1 to 10 do
begin
statements
end

Testing on Ubuntu 16.04 and cygwin results in this error:
-bash: syntax error near unexpected token `:='

A logical replacement would be:

for x in {1..10}
do
echo $x
done

Improve the 2.4 Loops section.

I see two issues with your for loops section.

  1. Typo; In your 1st example. You use "end" to end the for loop, that is wrong it should be "done".
  2. It would be better to show some working examples

Instead of this:

for name [in list]
do
  statements that can use $name
done

How about doing it this way:

for name in one two
do echo $name
done

Example output:

one
two

Anther for loop example:

more list.txt
one
two
for name in $(more list.txt)
do echo $name
done

Example output:

one
two

Currently a user of the can't just cut and past the code into there terminal to run. This way they can do that to test and learn how it works.

Also maybe add a read line section to the while loop section.
Example:

more list.txt | while read line
do
  echo "$line"
done

This kind of loop is good for varibles with spaces in.

I can do a pull request if you want and do it for you, just let me know.

Issue: Case-Insensitive File Search in Git Repository

Users often encounter difficulties when searching for files within the repository due to case-sensitive filename searches. For example, if a user attempts to find a file named "ReadMe.md" but searches for "README.md", the case sensitivity of the search command will result in a failure to locate the file. This issue can cause unnecessary confusion and hinder productivity.

Example Scenario
Consider the following situation: A user is trying to locate all PNG files in their home directory but forgets the exact casing of the filenames.

Current behavior using find:

$ find /home/user1 -name '*.png'

If the filenames are actually in uppercase (e.g., IMAGE.PNG), the above command will not return any results, leading the user to believe that the files do not exist.

Suggested Improvement
To alleviate this issue, it is recommended to use the -iname option instead of the -name option with the find command. The -iname option performs a case-insensitive search, thereby improving the user experience and ensuring that files are found regardless of their casing.

Recommended Command
Instead of:

$ find /home/user1 -name '.png'
Use:
$ find /home/user1 -iname '
.png'
This command will successfully locate files like image.png, IMAGE.PNG, and Image.PNG, regardless of their case.

image

Add for using brace or nested brace expansion

There is an other use of for, it's very useful in some case

for char in {a..z}; do
    echo$ char
done

It will be print a b c ... x y z
or

for i in {{a..m},{0..9},{n..z}}; do # don't have any space between commas
    echo $i
done

It will be print a b c ... k l m 0 1 2 ... 7 8 9 n o u ... x y z

Differentiate common linux binaries from Bash

There should be at least an introduction saying that the presented binaries (grep, find, mkdir ...) aren't part of bash and can be used by any other shell or programming language and are just part of unix commonly used binaries. Just let them know this isn't Bash specific.

Bash builtins should at the contrary be highlighted (export, cd ...) to be differentiated from the binaries.

A bash guide shouldn't use zsh for examples

Instead of using this to demonstrate export:

$ export
SHELL=/bin/zsh
AWS_HOME=/Users/adnanadnan/.aws
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LESS=-R

$ echo $SHELL
/usr/bin/zsh

let's omit zsh, which is an alternative to bash. That's confusing, and at cross-purposes with this tutorial.

I suggest updating that part of the README to this:

$ export
AWS_HOME=/Users/adnanadnan/.aws
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LESS=-R

$ echo $AWS_HOME
/Users/adnanadnan/.aws

String subtitution Bash version

I think it's worth mentioning that some of the function works on Bash 4+.
I'm pretty certain about ${string^^} etc. not sure about the other functions.

I think that specifying the working version will be super beneficial to mac users (with bash 3) that might get a little disappointed to find some things work differently on their machine.

uniq output mistake

The output of sort example.txt | uniq isn't quite right. Given the input file, it should be:

a
b
c
d

Missing builtins

Hi,
The guide is awesome, will be very useful for a beginner. (y)

bash shell builtin help is missing in the guide.

$ help

GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.

A star (*) next to a name means that the command is disabled.

 job_spec [&]                                                        history [-c] [-d offset] [n] or history -anrw [filename] or hist>
 (( expression ))                                                    if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]...>
 . filename [arguments]                                              jobs [-lnprs] [jobspec ...] or jobs -x command [args]
 :                                                                   kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or ki>
 [ arg... ]                                                          let arg [arg ...]
 [[ expression ]]                                                    local [option] name[=value] ...
 alias [-p] [name[=value] ... ]                                      logout [n]
 bg [job_spec ...]                                                   mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callb>
 bind [-lpsvPSVX] [-m keymap] [-f filename] [-q name] [-u name] [->  popd [-n] [+N | -N]
 break [n]                                                           printf [-v var] format [arguments]
 builtin [shell-builtin [arg ...]]                                   pushd [-n] [+N | -N | dir]
 caller [expr]                                                       pwd [-LP]
 case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac          read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N ncha>
 cd [-L|[-P [-e]] [-@]] [dir]                                        readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [-C cal>
 command [-pVv] command [arg ...]                                    readonly [-aAf] [name[=value] ...] or readonly -p
 compgen [-abcdefgjksuv] [-o option]  [-A action] [-G globpat] [-W>  return [n]
 complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action] [-G >  select NAME [in WORDS ... ;] do COMMANDS; done
 compopt [-o|+o option] [-DE] [name ...]                             set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
 continue [n]                                                        shift [n]
 coproc [NAME] command [redirections]                                shopt [-pqsu] [-o] [optname ...]
 declare [-aAfFgilnrtux] [-p] [name[=value] ...]                     source filename [arguments]
 dirs [-clpv] [+N] [-N]                                              suspend [-f]
 disown [-h] [-ar] [jobspec ...]                                     test [expr]
 echo [-neE] [arg ...]                                               time [-p] pipeline
 enable [-a] [-dnps] [-f filename] [name ...]                        times
 eval [arg ...]                                                      trap [-lp] [[arg] signal_spec ...]
 exec [-cl] [-a name] [command [arguments ...]] [redirection ...]    true
 exit [n]                                                            type [-afptP] name [name ...]
 export [-fn] [name[=value] ...] or export -p                        typeset [-aAfFgilrtux] [-p] name[=value] ...
 false                                                               ulimit [-SHabcdefilmnpqrstuvxT] [limit]
 fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]    umask [-p] [-S] [mode]
 fg [job_spec]                                                       unalias [-a] name [name ...]
 for NAME [in WORDS ... ] ; do COMMANDS; done                        unset [-f] [-v] [-n] [name ...]
 for (( exp1; exp2; exp3 )); do COMMANDS; done                       until COMMANDS; do COMMANDS; done
 function name { COMMANDS ; } or name () { COMMANDS ; }              variables - Names and meanings of some shell variables
 getopts optstring name [arg]                                        wait [-n] [id ...]
 hash [-lr] [-p pathname] [-dt] [name ...]                           while COMMANDS; do COMMANDS; done
 help [-dms] [pattern ...]                                           { COMMANDS ; }`

And also Info utility
info

These things help a user to know where to find what he/she needs.

Thank you for sharing

Thank you for sharing, I am deeply inspired. I'd like to introduce you to an online programming platform called codigger. This platform provides a rich programming environment and resources that are especially suitable for infrastructure engineers like you to script, debug, and share. I cordially invite you to give codigger a try. If you have any questions or suggestions during use, you can contact us at any time, and we will try our best to provide you with help and support.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.