Sponsored Content
Full Discussion: Text redirection
Top Forums UNIX for Dummies Questions & Answers Text redirection Post 302608097 by Leo_Boon on Friday 16th of March 2012 06:35:50 AM
Old 03-16-2012
Ok, so here's a sample of what I have:
Code:
# Big table
Feature      100-0%    90-10%    80-20%    70-30%    60-40%    50-50%    40-60%    30-70%    20-80%    10-90%    0-100%
cdmass       12.010    10.809    9.6080    8.4070    7.2060    6.0050    4.8040    3.6030    2.4020    1.2010    0.0000
hdmass       1.0080    0.9072    0.8064    0.7056    0.6048    0.5040    0.4032    0.3024    0.2016    0.1008    0.0000
cdradius     0.8780    0.7902    0.7024    0.6146    0.5268    0.4390    0.3512    0.2634    0.1756    0.0878    0.0000
hdradius     0.1350    0.1215    0.1080    0.0945    0.0810    0.0675    0.0540    0.0405    0.0270    0.0135    0.0000

This is the first 5 lines of the master table, as a simple text file edited with vim. Each column has values for that particular percentage combination: the first one for 100-0, the second for 90-10 and so on. There are another 50 or so lines after that with more values of different features at that percentage combination.
My output looks like this:
Code:
# Modifications to force field
MASS
cd 12.01        0.878                                       Carbon
hd 1.008        0.135                                       Hydrogen 
hm 1.008        0.135                                       Other Hydrogen

In particular, this is the 100-0 combination. The format of the output is fixed: this is the way it has to be in order to be read by the program I'm using. There are another 40 or so lines after that for the remaining features and parameters.
In the third line, starting with cd, there are two values which vary in each percentage combination. The script needs to read the value from the table and write it in the correct column. For example, to prepare the 90-10 output file, I want it to read the third column on the third line (10.809) and write that down in the second column of the third line of the output file, then take the third column on the fifth line (0.7902) and write it on the third column of the third line of the output file. I want this to be repeated for every other parameter. I don't care if I need many lines to specify where everything goes, as long as it's automated. Is there a way to do this?
My first idea was to extract each column of the table in a temporary, intermediate file, then copy across from this to a blank output file, which has XXXXX instead of numbers, by giving a command to substitute the first XXXXX it finds with the first value of the column, then the second with the second and so on. What I don't know what to do is how to redirect the substitution from a file to another file.
 

9 More Discussions You Might Find Interesting

1. Programming

Help with redirection

Here is my problem. I don't know make this redirection thing work. The output file (called output.c) looks like this #include<stdio.h> int main() { int k; int m; print f("%d\n", k); printf("%d\n", m); return 0; } the input file(called input.c) is this #include<stdio.h> int... (2 Replies)
Discussion started by: Shallon1
2 Replies

2. Shell Programming and Scripting

redirection stdin

hello all, I need to create a password change utility for a database. I need to gather at the command line the username, password and database sid. I have the program currently doing this. What I would like to do is not have the new password appear on the screen when I do my read command.... (2 Replies)
Discussion started by: whited05
2 Replies

3. Shell Programming and Scripting

redirection

Hi, The code below works, it's a part of a bash shell script that serve to search a pattern $pattern_da_cercare in the files contained in a directory $directory_iniziale. Now the proble is: How can I redirect stderr to a file? PS: so I want to redirect ALL the errors to a file. I tryed... (9 Replies)
Discussion started by: DNAx86
9 Replies

4. UNIX for Dummies Questions & Answers

Help with Redirection

Hi Guys, I m new to UNIX and new to this forum. Was wondering if someone can help me understand redirection (standard input output pipeline etc) for starters, not too sure what this would mean who | sort > sortedfile | pr | lp im starting to understand common commands but when throwing... (2 Replies)
Discussion started by: jmack123
2 Replies

5. Homework & Coursework Questions

Finding/replacing text and redirection help

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: What command would rename "sequentialInsert", in ~cs252/Assignments/commandsAsst/project/arrayops.h, to... (2 Replies)
Discussion started by: lothwen
2 Replies

6. Shell Programming and Scripting

I/O redirection

Hello everyone,I'm reading a book and there's code fragment: exec 3>&1 ls -l 2>&1 >&3 3>&- | grep bad 3>&- exec 3>&- It says that the red part of that code does not close fd 3 but the green does close the fd 3.I can't understand that.....Why?Any predicate will be appreciated.:) (18 Replies)
Discussion started by: homeboy
18 Replies

7. Shell Programming and Scripting

Redirection

Hello All, I am using the below script to gather various tools running by the user, we have more than 100 tools running on the server so my challenge is to redirect memory & cpu load to the file with the name of the tool.so am using the below script i am stucking how to redirect to the file... (2 Replies)
Discussion started by: ajaincv
2 Replies

8. Solaris

solaris redirection

Hi I am using solaris 10. When running a grep command with multiple files the output is the same as the order of the input. As soon as I pipe the output to another command then it seems that standard error takes precedence, over standard output and gets sent to the pipe first. ie grep -c... (7 Replies)
Discussion started by: chronics
7 Replies

9. UNIX for Dummies Questions & Answers

about different redirection

explain the redirections 1>, 2>, 3>, ..... and 1< ,2<,3<..... where we use these things thanks Thread moved from AIX forum (2 Replies)
Discussion started by: tsurendra
2 Replies
cvcredir(7D)							      Devices							      cvcredir(7D)

NAME
cvcredir - virtual console redirection driver DESCRIPTION
The cvcredir virtual console redirection driver is a STREAMS-based pseudo driver that supports the network console provided on some plat- forms. The cvcredir driver interfaces with the virtual console driver cvc(7D), and the virtual console daemon, cvcd(1M). The cvcredir driver receives console output from cvc and passes it to cvcd. It receives console input from cvcd and passes it to cvc. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Architecture |Sun Enterprise 10000 | | |servers, Sun Fire 15K | | |servers | +-----------------------------+-----------------------------+ |Availability |SUNWcvc.u | +-----------------------------+-----------------------------+ SEE ALSO
cvcd(1M), attributes(5), console(7D), cvc(7D) Sun Enterprise 10000 SSP Reference Manual Sun System Management Services (SMS) Reference Manual SunOS 5.11 15 Sep 2000 cvcredir(7D)
All times are GMT -4. The time now is 02:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy