Please wrap all code, files, input & output/errors in CODE tags (highlight and press the CODE toolbar button)
It is easier to read as code because it is mono-spaced and preserves multiple spaces for indenting and fixed-width data. I have adjusted your initial post for you. If you click on the edit button, you can see how.
My first suggestion is to lose the $(cat $DATAFILE..... bit. It is far more efficient to have your loop like this:-
The output is written as one operation to the file rather than lots of separate statements, which (by the way) overwrite the file, so you will only actually see the last record being output. You also write the output line for every input line, so you will get a variety of output being built up as records are read. As the values are not reset, after the first complete 'chunk' of the output, the next will start with the old values filled in which is probably confusing.
If you are certain of your input format, you can probably do this:-
When it comes to processing your lines to get the values you want, you are also calling far more steps than you need. With ksh or bash, you can split up the line as you read it. You need just the first item of each line, so this brings my first suggested code to this:-
Does that help?
If I've confused you, I apologise. If the script produces errors, please paste them in to the thread, wrapped in CODE tags of course, and I will have another think.
Kind regards,
Robin
Last edited by rbatte1; 02-15-2018 at 08:18 AM..
Reason: Added spaces in output as required.
Hi Experts,
I am writing a python script to grep string from file and display output in csv file as in attached screenshot
https://drive.google.com/file/d/1gfUUdfmQma33tz65NskThYDhkZUGQO0H/view
Input file(result_EPFT_config_device)
Below is the python script i have prepared as of... (1 Reply)
Hello all
I'm looking to write a simple script (ksh/sh/bsh) to read user input and write it to a file (adding each time) until the user enters QUIT at which point I'm hoping to ask some more questions.
Any help much apprecited (2 Replies)
Hi
I'm looking to write a simple ksh loop reading user input (and write it to a file) until the user enters QUIT at which point I want it to continue.
Does anyone have an example of this type of loop?
Any help much appreciated
Cheers (2 Replies)
I've got a file that looks like this (spaces before first entries intentional):
12345650-000005000GL140227 ANNUAL HELC FEE EN
22345650-000005000GL140227 ANNUAL HELC FEE EN
32345650-000005000GL140227 ANNUAL HELC FEE EN
I want to read through the file line by line,... (6 Replies)
Hi ,
i am having an file which contains 5 file_name data, i need to read the file name and will perform certain operation and generate out file names with named as 5 individual file_names
for eg:
file.txt contains
file_name1.txt|hai
file_name2.txt|bye
file_name3.txt|how... (3 Replies)
I've been asked if I can write a "quick" little ksh script that will do the following:
java java_class_file /dir/input_file.xml /dir/output_file.xml
I'm a complete newbie with ksh so any help would be appreciated.
This is on AIX and java is found in
/usr/java5/jre/bin/java (4 Replies)
Hi folks..
i got a requirement to red multiple directories from STDIN and store them to a variable.
ex:-
echo "Enter directory to add:"
echo " Enter directory to add:"
read value till there is input and when there is no input close the read loop and store variable into an array
... (1 Reply)
Hello there, I am posting to seek help with a KSH script,
I am making a simple calculation program where the user can enter as many numbers as they like, I am getting their input using the read command, however I am not sure how to repeat doing this and storing the input in to new variables... (7 Replies)
Friends,
This is what I need:
I will pass a CSV file as an input, and I want my shell to be reading that CSV file, and based on the parameters it should generate SQLs and write those SQL in a different file in the same location.
I'm new to Shell scripting. I'm currently working on a... (25 Replies)
Friends,
This is what I need:
I will pass a CSV file as an input, and I want my shell to be reading that CSV file, and based on the parameters it should generate SQLs and write those SQL in a different file in the same location.
I'm new to Shell scripting. I'm currently working on a... (1 Reply)