Visit Our UNIX and Linux User Community


Bash Programming. Could anyone help me?


 
Thread Tools Search this Thread
Operating Systems Linux Bash Programming. Could anyone help me?
# 1  
Old 10-09-2014
Bash Programming. Could anyone help me?

Hi! I'm new in bash programming and I need to make an script that reads a txt file line by line (every line is like "Name;FirstLastName;SecondLastName;Sex") and has to give every student 3 random marks, its average and add a counter if they are male/female and if they passed. I've been trying with the "read while" function but i don't know how to do the script. Could anyone help or explain me how it works or how should I do this? I would be very grateful. Smilie

Post Edition: Output needs to be a new txt, not the same.
# 2  
Old 10-09-2014
Welcome to Forums,

Is this homework/assignment? There are specific forums for these.

What have you tried so far?

What output/errors do you get?
This User Gave Thanks to Akshay Hegde For This Post:
# 3  
Old 10-09-2014
This explains how to read a file line-by-line. Pay attention to the non-whitespace delimiter example.

BashFAQ/001 - Greg's Wiki
This User Gave Thanks to neutronscott For This Post:
# 4  
Old 10-09-2014
Yes, this is homework. Sorry, I did't know there are specific forums. I've benn trying the read while function but I only takes every line as a unique value, later I tried to change the IFS but it didn't work. I got no errors, but it does not get the in values correctly separated, so it won't work when I'll try to solve the 2nd part.
# 5  
Old 10-09-2014
Quote:
I've benn trying the read while function but I only takes every line as a unique value, later I tried to change the IFS but it didn't work. I got no errors, but it does not get the in values correctly separated, so it won't work when I'll try to solve the 2nd part.
Please show what you have tried.
Quote:
Yes, this is homework. Sorry, I did't know there are specific forums.

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
This User Gave Thanks to Corona688 For This Post:

Previous Thread | Next Thread
Test Your Knowledge in Computers #306
Difficulty: Easy
The HTML4 standard was published in 2014.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Chunks of bash shell programming

I am going to provide a chunks of codes that I do not understand. Please help with them in a layman's terms. 1) ${DEBUG:-0} -------------------------------------------------------------------------- 2) print "${1}" ... (7 Replies)
Discussion started by: lg123
7 Replies

2. Shell Programming and Scripting

ctrl-c in bash script - Programming

Hi All, I need to place a ctrl-c interrupt in a bash script, there is no other way, it has to be done :) can someone please advise how would I go about this? i want to use ctrl c in below code, after the code excution of just 1 min or 1sec java Cspsamp 111.19.5.172 7025 rd1... (6 Replies)
Discussion started by: aish11
6 Replies

3. Homework & Coursework Questions

Bash Shell Programming assignment.

Please take a look I am stuck on step 4 1. The problem statement, all variables and given/known data: #!/bin/bash ### ULI101 - ASSIGNMENT #2 (PART A) - DUE DATE Wed, Aug 3, 2011, before 12 midnight. ###==================================================================================== ###... (13 Replies)
Discussion started by: almirzaee
13 Replies

4. Shell Programming and Scripting

Bash programming help

Hello all; I have little knowledge of bash programming, and I was wondering if you could help me out. I would like to create a bash script, as detailed below. process.sh is the bash script itself list.dl is a text file. In this text file, the first line is the directory from... (1 Reply)
Discussion started by: tehalexf
1 Replies

5. Shell Programming and Scripting

Example in Pro Bash Programming book problem

I am going through the examples in the book "Pro Bash Programing" which is quite a good book on bash programing. Just a word of warning about the example script called sa that simply shows command line arguments. In CentOS 5.5 there is a program called sa already on the system. Boy did that throw... (0 Replies)
Discussion started by: simusphere
0 Replies

6. Shell Programming and Scripting

Bash time and programming

I have inherited a C++ program which does not manage it's memory at all. It has a whole bunch of 'new' variables without many deletes. I believe it was the programmers intent to let the OS clean up. Correct me if I am wrong, but I believe the unix/linux systems clean up after the program... (1 Reply)
Discussion started by: JDKunk
1 Replies

7. Shell Programming and Scripting

bash programming

how do you allow a user to input a particular group name as an argument?? thnx for your time. (2 Replies)
Discussion started by: bumdeal2
2 Replies

8. Shell Programming and Scripting

Bash Programming

Write a Shell script to analyse the disk usage of students in a particular class. The program should allow the user running the script to input the particular class name (group name) as an argument to the script. The script should create a file called “logfile” in the home directory of the user... (2 Replies)
Discussion started by: bumdeal2
2 Replies

9. Shell Programming and Scripting

help bash programming

how to i grep a keyword which ignore upper case or lower case. for an example : user enter CoUcH and the grep also can grep couch which in text.txt although upper or loever case is different .. how to do that ? any idea? (1 Reply)
Discussion started by: CheeSen
1 Replies

10. Shell Programming and Scripting

Programming in ksh and not in bash

Hi all.... I was wondering if there is a lot of differences between /bash and ksh programming. Im learning about bash programming, but all what I had read in this forum, points me to learn more about ksh over bash. Is that right and why? Unfortunately, I can’t write ksh progs on my work,... (2 Replies)
Discussion started by: TARFU
2 Replies

Featured Tech Videos