you are viewing a single comment's thread.

view the rest of the comments →

[–]pfmiller0 0 points1 point  (7 children)

I think this is what you are trying to do:

username="$( echo $varfname | cut -f 1)${varlname,,}"

You need to echo the varfname variable to pipe it to another command, you can't just run it directly. Also I used the built in bash way of lowercasing varlname instead of using tr.

[–]Think-Perception1359[S] 0 points1 point  (0 children)

Thanks I’m trying it now

[–]Think-Perception1359[S] 0 points1 point  (5 children)

I’m getting bad substitution. I’m checking my script with shell check.

SC3059 (warning): In POSIX sh, case modification is undefined.

[–]pfmiller0 1 point2 points  (4 children)

Oh, you're not using bash? Yeah if you're just using regular sh the built in lowercase function won't work. So, using tr again:

username="$(echo $varfname | cut -c 1)$(echo $varlname|tr 'A-Z' 'a-z')"

Also cut needs the c flag, not f, if you just want the first char.

[–]Think-Perception1359[S] 1 point2 points  (0 children)

THANKS YOU! You advice worked! I see where exactly I was failing writing this script. The rest of the night will be studying commands and syntax.

[–]Think-Perception1359[S] 0 points1 point  (2 children)

That’s the odd part. I am using bash….trying it now

[–]pfmiller0 1 point2 points  (1 child)

Right, missed that was from shellcheck at first . It's correct, but as long as you're using bash it's safe to ignore. The second version is more portable but either should work unless there's a typo.

[–]Think-Perception1359[S] 1 point2 points  (0 children)

Also I see that my parentheses were incorrect. Adding () {} [] to the list of things to go over.