Sponsored Content
Top Forums Shell Programming and Scripting Result of 'cut' into variable Post 302915342 by RavinderSingh13 on Tuesday 2nd of September 2014 11:20:36 AM
Old 09-02-2014
Hello API,

Welcome to the forum.
I can see there are only 85 characters present in the line as follows.

Code:
echo "Company                 001.239879123.OB1X.672W12.STS                    UNOLD.001.02" | awk '{print length($0)}'

Output is as follows.

85
So kindly let us know your complete requirement so that we can help you.


EDIT: Seems you have modified the post now. If you want to take the complete line into a variable then I don't think that there is a need of using cut
command there. If you want to work on lines of a file you can use while loop it will read file line by line and you can perform your operation as per your requirement.

Posted by Makarand Dodmis:
Quote:
try
Code:
$ header=`cut -c1-160 t.dat | head -1`$ echo "$header"Company 001.239879123.OB1X.672W12.STS UNOLD.001.02

Hello Makarand:
your solution will not have space in the variable as per user query, user needs the spaces in variable.


Thanks,
R. Singh

Last edited by RavinderSingh13; 09-02-2014 at 12:35 PM.. Reason: Adding solution as user has modified actual post
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

populate variable from remote result

Hi there i am trying to pass the result of a remote command into a variable into my script ie #!/bin/sh var = `ssh remote_box 'uname'` echo $var but all i get back is ./script.sh: var: not found However when i add a -x to put it into diag mode i get the following + ssh... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

2. UNIX and Linux Applications

How to get a result of a cmd into variable?

Hi , I am trying following . I need to get a result of an autosys cmd into a unix variable. The autosys cmd is autostatus -G jpm_day_today Please help me in storing the value returned by this cmd into a unix variable. Appreciate your time to read this post. (1 Reply)
Discussion started by: manchau
1 Replies

3. Shell Programming and Scripting

Assign result to variable

Hi friends, firstly, i can run following expression and i took 100 value. sqlplus -s username/password@TTTEST @umt.sql umt.sql exists "select t.deger from parametre t where t.id=30". result of this query =100 i need to assign this value(100) to variable(for example x... (2 Replies)
Discussion started by: temhem
2 Replies

4. Shell Programming and Scripting

Taking sed result in a variable

Hi All, How can i take the following code having three seds into a variable : echo "$DateFileFormat" | sed 's/\./\\\\./g' | sed 's/\$/+/g' | sed 's/\#/'$job_date'/g' I want to get the result stored in a script variable i tried var2=`echo "$DateFileFormat" | sed 's/\./\\\\./g' |... (4 Replies)
Discussion started by: abhinav192
4 Replies

5. Shell Programming and Scripting

result in variable

Hi all, I'll try to get a result from a search with "awk" into a variable. It works for those examples: findfirstline=`awk 'BEGIN{ mycount = 1 } { if(mycount == 1 && /^Video/){ row=NR; print row; mycount = 0; }}' ${i}` findlastline=`awk '/^Video/ {row=NR} END{print row}' ${i}` But it... (6 Replies)
Discussion started by: tempestas
6 Replies

6. Shell Programming and Scripting

Print the whole line which contains the result of the command cut

Hey everyone I have a file 'agenda' which contains: Object Day Month Year Birthday 09 02 2012 i want to extract from a script the line which contains the day the user typed. for example if he type 09 the line is showed using... (4 Replies)
Discussion started by: Goldstein
4 Replies

7. Shell Programming and Scripting

How to combine two variable result?

Hi, i have two variables i.e lck_ckm_customer=ckm_customer and(present in some script A) table=ckm_customer(present in script B) in script B i am executing this part if ; then --- ---- ---- fi Now, while comparing in my log file i am getting this result if but i... (2 Replies)
Discussion started by: gnnsprapa
2 Replies

8. UNIX for Dummies Questions & Answers

I save the result in a variable

I have friends that this command worked perfectly, but I would like to save the result in a variable, which I have not achieved var=prueba.txt echo $var | cut -d "." -f 1 prueba I need to do this but does not work me salida=echo $var | cut -d "." -f 1 echo "result:$salida" ... (8 Replies)
Discussion started by: tricampeon81
8 Replies

9. Shell Programming and Scripting

Store result variable

Friends have the following problem: cat $PATH_DAT/mr.txt | nawk 'BEGIN { CantPnt=0; NumReg=0; FS="|" } { NumReg++ CantPnt=CantPnt+int($2) } END{ printf... (5 Replies)
Discussion started by: tricampeon81
5 Replies

10. Shell Programming and Scripting

CUT command not giving correct result inside loop

Hi, i have a source file and have 3 columns and separated by "|" .i want to split this 3 columns in different variable.When i am executing this values indivisually giving correct result but when the same execute inside a for loop,it's giving issues. Src file(jjj.txt) -------... (8 Replies)
Discussion started by: raju2016
8 Replies
UNITS-FILTER(1) 					     units-filter User Manual						   UNITS-FILTER(1)

NAME
units-filter - is a parser for physical and chemical quantities SYNOPSIS
units-filter -s -o -l DESCRIPTION
units-filter is a basic standalone parser written in C language, flex and bison. It inputs strings like "1.5e3 nN.m.s^-1" (it could be the time growth ratio of a torque) and outputs the value in standard SI unit, followed by the physical dimension of this value. OPTIONS
-s Like Significant. Takes in account the number of significant digits. For example 1.0 m contains 2 significant digits, while 0.00100 contains 3 significant digits. It is possible to enforce the number of significant digits by using a special syntax : if units-filter parses the input "1.0m#6", it interprets it as a value with exactly 6 significant digits, like "1.00000 m". The number following the # sign is the forced number of significant digits. The number of significant digits appears just before the last zero in the output of the command (this zero is a placeholder for future extensions). -o Like Output. Outputs a correct representation of the physical quantity with its physical unit in the International System notation. There may be some simplification with usual units. For example, a newton will be represented by the unit N in place of m.kg.s^-2. The value is expressed as a floating number with one digit before the decimal point, and as many digits in the mantissa as necessary to fit the desired number of significant digits (see an example below). It is possible to enforce the output unit : just add a colon and the desired unit at the end of the input. If this unit is homogeneous with the former one, it will be used to format the output. -l Like LaTeX. Outputs a correct representation of the physical quantity with its physical unit in the International System notation, in LaTeX language. EXAMPLES
Establish the SI value and unit exponent of a quantity in the mksa system: ~$ echo 1.5e3 nN.m.s^-1 | units-filter 1.5e-6 2 1 -3 0 0 0 0 which means : 1.5e-6 (SI unit) m^2.kg.s^-3 Compare different physical quantities: ~$ e1=$(echo "1.2e-3 V" | units-filter) ~$ e2=$(echo "1200e3 nWb/s"| units-filter) ~$ if [ "$e1" = "$e2" ]; then echo ok; else echo ko; fi ok ... which emphasizes that webers by unit time are the same as volts. Playing with the number of significant digits: ~$ echo "0.00100m" | src/units-filter -s 0.001 1 0 0 0 0 0 0 3 0 ~$ echo "0.00100m #2" | src/units-filter -s 0.001 1 0 0 0 0 0 0 2 0 Giving a value for the relative precision: ~$ echo "1kV~2" | units-filter -o 1e+03 V +-2% Turning on the LaTeX output: ~$ echo "1kohm+-2%" | units-filter -l 1 imes 10^{+03}, Omega pm 2,\% Turning on the output of a canonical physical notation: ~$ echo "1.0 m.kg.s^-2 #7" | units-filter -o 1.000000e+00N Choosing a non-standard unit for the output: ~$ echo 1800C:A.h| units-filter -o 5.000e-01 A.h KNOWN BUGS
Few units out of the mksa system are successfully parsed. AUTHOR
Georges Khaznadar <georgesk@ofset.org> Wrote this manpage. COPYRIGHT
Copyright (C) 2009 Georges Khaznadar Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or (at your option) any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. units-filter 11/19/2011 UNITS-FILTER(1)
All times are GMT -4. The time now is 07:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy