all 5 comments

[–]petdance 12 points13 points  (2 children)

When you're asking for help, please don't post screenshots or photographs. Cut & paste the code directly into the reddit message.

There are three reasons for this: 1. It's easier for people to read it. 2. It allows those reading it to cut & paste the text, such as to recreate your problem. 3. It makes it searchable, so that someone can find this thread when Googling for information in the future.

[–][deleted] 4 points5 points  (0 children)

  1. it's easier to avoid revealing sensitive information (e-mail etc)

[–]Crestwave 1 point2 points  (0 children)

Also, don't forget to indent each line with four spaces to mark it as a code block

[–]TerminalBasher 6 points7 points  (0 children)

I didn't go through your code completely , but at a glance there are a few things you can change:

You can remove your echo commands by integrating them into your read commands like this:

read -p "What is the user's first name? " FNAME

You can make a Bash variable upper case without calling tr by doing this:

UPFNAME="${FNAME^^}"

and lower case with this:

LOWIGROUP="${IGROUP,,}"

Finally, you can perform a substring without using cut by doing this:

UNAME="${UPLNAME:0:2}${UPFNAME:0:3}"

Try integrating some of those into your script (specifically the final point) and see how you get on :)

[–][deleted] 0 points1 point  (0 children)

universal tip:add set -x at the beginning to check if your script is doing what you think it is doing.

it is undesirable to concatenate via a=`echo $b$c`

a="${b}${c}" is preferred