Need to write a script user.sh that parses name & password

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:
    Write a script called user.sh that parses the name and password of given in a file ( user.txt ) and creates the user using first letter of first name followed by full last name. the password should be the third field.
First name   Last Name     Password
Johanna       Osbourne      TeSTiNg143
  1. Relevant commands, code, scripts, algorithms:
First name   Last Name     Password
Johanna       Osbourne      TeSTiNg143
  1. The attempts at a solution (include all code and scripts):
    #!/bin/bash
  for row in `cat $1`
  do
      if [ $(id -u) -eq 0 ]; then
  

          username=${row%:*}
          password=${row#*:}
          #echo username
          #echo password
  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
    CUNY Medgar EVers, Brooklyn, ny, Prof. harris CIS 440

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

We are not here to do your homework for you. We will be happy to help you figure out what needs to be fixed if you make an honest effort to do the work yourself and need some help figuring out why something isn't working.

Writing a for loop that has no end, containing an if statement that has no end, and splitting fields out of a line based on finding colon characters when there are no colon characters in your input file doesn't give us the impression that you have made an honest effort to solve your problem.

Please show us your entire script (using CODE tags), add comments to your code explaining what each statement is trying to do, show us any output you are getting from your script (using CODE tags), and show us the output you are trying to get from your sample input (using CODE tags).

Explain what you think is going wrong and show us where you are stuck.

1 Like