Sponsored Content
Top Forums Shell Programming and Scripting How to input parameters and add Columns? Post 302902752 by ali.seifaddini on Thursday 22nd of May 2014 05:03:06 AM
Old 05-22-2014
How to input parameters and add Columns?

Hello and good day

I am not familiar with programming. I have text files and I would like to:

1) edit script to input "a" and "b" parameters by users

2)put input directories in loop :
Something like this:
Ex: For i in /usr/desktop/input/SG*

3)add 2 more columns and performing arithmetic operations.

4)add name to column

(my files start with SG; Ex: "SG140101120000.CAP5xyz.txt" )

I found this script, but it is not complete.
Code:
#! /bin/bash
echo "a value"
read a 
echo "b value"
read b
For i in SG*;
do
awk '{$6=($1-64)/2 ;$7=((10^($6/10))/$a)^(1/$b) ; print}' OFS="\t" $i > /root/Desktop/decoder/output_gr_ubrb/1/$i.txt;
done

Orginal txt file:

Code:
$1      $2            $3             $4
74   3.99166 101.37082  2.000
74   3.99166 101.37834  2.000
75   3.98416 101.37082  2.000
75   3.98416 101.37834  2.000
81   3.96916 101.29571  2.000
  0   3.96166 101.28820  2.000
 82   3.96166 101.29571  2.000
 85   3.96167 101.31073  2.000

Expected result:
Code:
$1         $2             $3                $4                  $5        $6
74	3.99166	101.37082	2.000		5	0.0748783
74	3.99166	101.37834	2.000		5	0.0748783
75	3.98416	101.37082	2.000		5.5	0.0804649
75	3.98416	101.37834	2.000		5.5	0.0804649
81	3.96916	101.29571	2.000		8.5	0.12391
0	3.96166	101.28820	2.000		-32	0.000364633
82	3.96166	101.29571	2.000		9	0.133155
85	3.96167	101.31073	2.000		10.5	0.165237

Thanks in advance

Last edited by ali.seifaddini; 05-22-2014 at 07:08 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Accept input parameters

Dear All, I got a table creation file in a standard format. I need to accept parameters from the user & then based on the input change the data in the file. For. eg. i will accept the database name, dbspace name & user name from the user and accordingly change the same in the table creation... (2 Replies)
Discussion started by: lloydnwo
2 Replies

2. Shell Programming and Scripting

Input parameters

I have a script which take 3 input parameters 1st - a date (i.e. current date) 2nd - type (i.e. A) 3rd - limit (i.e. 40) normally the date parameter would be current date, so I thought I could do this calculate.sh $(date +%Y-%m-%d) A 40 however, it seems like it can't be done,... (3 Replies)
Discussion started by: mpang_
3 Replies

3. Shell Programming and Scripting

input parameters pls help!

Hi i am a newbie who is trying to input parameters into this script, but not sure where to start. The parameters that need to be input are the baseline label "abc.0111.BL " mantioned bellow, and database string "abc/abcp@db2 @counter.sql " Environment: Windows XP Running script: Cygwin 3.2 ... (2 Replies)
Discussion started by: yarik20
2 Replies

4. Shell Programming and Scripting

Validating Input parameters

Hi All, I have tried to use ckdate (sun) command in script. It checks the input parameter which should be in 'YYYYMMDD format. date=$( echo $1 | ckdate -f "%Y%m%d") | true if ] then print " success" else print "no success" fi But in whatever format i pass the parameter,... (3 Replies)
Discussion started by: Amit.Sagpariya
3 Replies

5. Shell Programming and Scripting

Verify input parameters

I have to write a script to verify input parameters; say esr should be YES or NO other wise the script should print an error. This is what i tried in my script but I get the following error : esr="YES" if ; then print " Error should specify esr options YES/NO" else esr =$esr fi ... (2 Replies)
Discussion started by: ramky79
2 Replies

6. Shell Programming and Scripting

Problem with Input parameters

Hi, I am facing a weird problem with input parameters. Please find more details about my problem below: a) I am executing a korn shellscript with 11 input parameters from "Appworx" tool (it's a scheduling tool) and immediately displaying those 11 parameter values in unixscript and noticed... (4 Replies)
Discussion started by: npk2210
4 Replies

7. Shell Programming and Scripting

Problem with input parameters

Hi I wrote a script which lists the content of a given directory. I have just one problem. If you give 2 or more parameters, then it gives a strange error. After that error, it gives also an error from my script, but normally it shouldn't give that error. Here's my script.You can test it. ... (3 Replies)
Discussion started by: hss
3 Replies

8. Shell Programming and Scripting

How can I take input parameters after the first one?

Hi, Is there a simple way to take input of parameters after the first one? As following example, if I assign others=$2, it only takes the second one, if I assign others=$@, it will include the first one. I may try to assign others="$2 $3 $4 $5 $6 $7 $8 $9", it looks very ugly and could missing... (1 Reply)
Discussion started by: hce
1 Replies

9. AIX

Input parameters

friends and I can validate whether to run the shell has input parameters m event date, I occasionally happen something like this does not work if $ 1 is null then echo has entered input parameters else echo "parameter ok" fi (2 Replies)
Discussion started by: tricampeon81
2 Replies

10. Shell Programming and Scripting

Search last column of INPUT.txt in TABLEs text and add correspond columns to INPUT.txt

Hi dears i use bash shell i have INPUT.txt like this number of columns different in one some row have 12 , some 11 columns see last column INPUT.txt CodeGender Age Grade Dialect Session Sentence Start End Length Phonemic Phonetic 63 M 27 BS/BA TEHRANI 3 4 298320 310050... (2 Replies)
Discussion started by: alii
2 Replies
COLUMN(1)						    BSD General Commands Manual 						 COLUMN(1)

NAME
column -- columnate lists SYNOPSIS
column [-tx] [-c columns] [-s sep] [file ...] DESCRIPTION
The column utility formats its input into multiple columns. Rows are filled before columns. Input is taken from file operands, or, by default, from the standard input. Empty lines are ignored. The options are as follows: -c Output is formatted for a display columns wide. -s Specify a set of characters to be used to delimit columns for the -t option. -t Determine the number of columns the input contains and create a table. Columns are delimited with whitespace, by default, or with the characters supplied using the -s option. Useful for pretty-printing displays. -x Fill columns before filling rows. Column exits 0 on success, >0 if an error occurred. ENVIRONMENT
COLUMNS The environment variable COLUMNS is used to determine the size of the screen if no other information is available. EXAMPLES
(printf "PERM LINKS OWNER GROUP SIZE MONTH DAY HH:MM/YEAR NAME " ; ls -l | sed 1d) | column -t SEE ALSO
colrm(1), ls(1), paste(1), sort(1) HISTORY
The column command appeared in 4.3BSD-Reno. BSD
June 6, 1993 BSD
All times are GMT -4. The time now is 03:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy