Sponsored Content
Homework and Emergencies Homework & Coursework Questions Loop to Convert a list from an input file and output it to another file Post 302798579 by Don Cragun on Wednesday 24th of April 2013 06:16:11 PM
Old 04-24-2013
Quote:
Originally Posted by AliTheSnake
Alright. The
Code:
>

deletes the content in the file
Code:
>>

appends it.
I changed > to >>
now i got this :


screenshot in attachments.
Something wrong in the tabling script?
What am i missing.
So it looks like you're getting all of your output (although the sample in your assignment showed two lines of headings and your output only shows one). It looks like your code to convert Centigrade to Fahrenheit is working correctly. So, what problem do you have left besides centering your output values under the appropriate headings? (You do realize that since the output values you've calculated vary from one to four characters, you will need to vary the number of spaces or tabs printed in front of the calculated values to center them, don't you?) I assume that you don't have access to the tabs utility yet, so you're probably better off just using spaces in your output rather than tabs. (And even if you do have access to the tabs utility, I wouldn't recommend using it for something like this.)

Do you know how to get bash to tell you how many characters are stored in a variable? Do you know what output column is at the center of each of your headings? With these two pieces of information, can you calculate how many leading spaces or tabs you need to print before the Centigrade value? (I'm not asking if you can do these calculations using bash; I'm asking if you understand the arithmetic required to determine how to center the strings you'll be printing.)

Do you know how to do integer arithmetic operations inside bash (without invoking bc or expr) yet? If not, it isn't a big deal, you have shown that you can use bc to perform any calculations you need to perform; it is just easier to use the bash built-in arithmetic evaluation tools. Do you know how to use a for loop in bash? Do you know how to use echo to output some characters without a trailing newline?

PS When posting code and sample input and output, please don't do anything special with the fonts. Using arial (a variable width font) instead of the default constant width font will make it almost impossible to get things lined up here.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

2. Shell Programming and Scripting

AWK Script to convert input file(s) to output file

Hi All, I am hoping someone can help me with some scripting I need to complete using AWK. I'm trying to process multiple fixed files to generate one concatenated fixed file in a standard format. The Input file is:- aaaa bbbbb ccccc 1 xxxx aaa bbb aaaa bbbbb ccccc 2 abcd aaa CCC... (9 Replies)
Discussion started by: jason_v_brown
9 Replies

3. Shell Programming and Scripting

split input data file and put into same output file

Hi All, I have two input file and need to generate a CSV file. The existing report just "GREP" the records with the Header and Tailer records with the count of records. Now i need to split the data into 25 records each in the same CSV file. id_file (Input file ) 227050994 232510151... (4 Replies)
Discussion started by: rasmith
4 Replies

4. UNIX for Dummies Questions & Answers

12. If an ‘88’ Record with BAI Code ‘902’ was found on input file and not written to Output file, re

This is my input file like this 03,105581,,015,+00000416418,,,901,+00000000148,,,922,+00000000354,,/ 49,+00000000000416920,00002/ 03,5313236,,015,+00231036992,,,045,+00231036992,,,901,+00000048428,,/ 88,100,+0000000000000,0000000,,400,+0000000000000,0000000,/ 88,902,+0000000079077,,/... (0 Replies)
Discussion started by: sgoud
0 Replies

5. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

6. Shell Programming and Scripting

How to read each line from input file, assign variables, and echo to output file?

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)
Discussion started by: Scottie1954
6 Replies

7. Shell Programming and Scripting

awk to reformat output if input file is empty, but not if file has data in it

The below awk improved bu @MadeInGermany, works great as long as the input file has data in it in the below format: input chrX 25031028 25031925 chrX:25031028-25031925 ARX 631 18 chrX 25031028 25031925 chrX:25031028-25031925 ARX 632 14... (3 Replies)
Discussion started by: cmccabe
3 Replies

8. Shell Programming and Scripting

Use while loop to read file and use ${file} for both filename input into awk and as string to print

I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix. I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice. Files:... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

9. UNIX for Beginners Questions & Answers

Need list of input and output parameter of task in a text file, using shell script

//file begin ===== //some code task abcd_; input x; input y,z; //some comment output w; //some comment reg p; integer q; begin //some code end endtask : abcd_ //some code //file end ===== expected output from above... (1 Reply)
Discussion started by: rishifrnds
1 Replies

10. Programming

creating separate output file for each input file in python

Experts, Need your help for this. Please support My motive is to create seperate output file for each Input Files(File 1 and File2) in another folder say(/tmp/finaloutput) Input files File 1(1.1.1.1.csv) a,b,c 43,17104773,3 45,17104234,4 File 2(2.2.2.2.csv) a,b,c 43,17104773,1... (2 Replies)
Discussion started by: as7951
2 Replies
UNEXPAND(1)								FSF							       UNEXPAND(1)

NAME
unexpand - convert spaces to tabs SYNOPSIS
unexpand [OPTION]... [FILE]... DESCRIPTION
Convert spaces in each FILE to tabs, writing to standard output. With no FILE, or when FILE is -, read standard input. Mandatory arguments to long options are mandatory for short options too. -a, --all convert all whitespace, instead of initial whitespace -t, --tabs=NUMBER have tabs NUMBER characters apart instead of 8 -t, --tabs=LIST use comma separated list of explicit tab positions --help display this help and exit --version output version information and exit AUTHOR
Written by David MacKenzie. REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
The full documentation for unexpand is maintained as a Texinfo manual. If the info and unexpand programs are properly installed at your site, the command info unexpand should give you access to the complete manual. unexpand (coreutils) 4.5.3 February 2003 UNEXPAND(1)
All times are GMT -4. The time now is 01:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy