How to do a script which read line by line /passwd using while
Hi everyone, I have to do several scripts and I have no idea of how to do this one: Make a script that read line by line the passwd file and prints in console.
Hope you understand couse my english is so bad as you can see. Our teacher told us something like this: #!/bin/bash while read line do echo $linea done < dispositive exit |
As this is a homework, I'll just say this:
1. give it a try based on what you've been taught; you wouldn't be asked to do this if you hadn't covered the relevant info in class/your books Show us what you've done 2. read/bookmark these http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ 3. see the LQ Rules re homework http://www.linuxquestions.org/linux/rules.html |
see.. i read a lot from the internet but i canīt do this script. Iīve done 17 scripts already, but canīt make thisone work.. im not trying someone to do my homework. Itīs just an exercise
|
So what seems to be the problem?
Based on what you have so far it seems to already be solved?? |
Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.
Your example from your teacher is almost there.... |
Quote:
|
#!/bin/bash
AR=/home/practicas/tp2/nuevo/home/practicas/tp1/passwd exec 3<&0 exec 0<$AR while read line do echo $line done exec 0<&3 I did this, what do you think now? how can i do that it prints line by line when the operator press the enter button? |
Quote:
There's no need for the redirects. Most simply you could change the script to Code:
#!/bin/bash EDIT: Maybe I will not post about why the execs are not working as intended because they are OK (for tidiness you could close 3 after the last line of the script). Are you sure that /home/practicas/tp2/nuevo/home/practicas/tp1/passwd exists? What happens if you change AR=/home/practicas/tp2/nuevo/home/practicas/tp1/passwd to AR=/etc/passwd? |
Quote:
|
ok ... so what doe it not do or error message does it give when you run it?
|
All times are GMT -5. The time now is 01:34 PM. |