Convert output to string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert output to string
# 1  
Old 01-14-2010
Convert output to string

Hi Guys,
is there any command to convert the output returned by the below command to string format:

Code:
sed 1!d filename

Output is :
108

---------- Post updated at 11:03 AM ---------- Previous update was at 11:00 AM ----------

Because i am using this output as string parameter and it is not accepting it.
# 2  
Old 01-14-2010
try:
Code:
"$(sed 1!d filename)"

# 3  
Old 01-14-2010
Nope it didn't work.
i dont want to pass command as parameter.
I want it output to be passed as string
# 4  
Old 01-14-2010
try:
Code:
val=$(printf "%s" $(sed 1!d filename))

# 5  
Old 01-14-2010
Quote:
Originally Posted by kam786sim
Nope it didn't work.
i dont want to pass command as parameter.
I want it output to be passed as string
This way you are not passing the command as a parameter, but its output as a single string. Please show us what you were trying to do and what your input file looks like.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert a String to a Number

I read in two numbers from a user but the number is a string. #!/bin/bash read -p "Enter first number: " num1 read -p "Enter second number: " num2 I know you can use the the "expr" or "bc" command to automatically convert the string to a number then add them together. But I don't want to add... (10 Replies)
Discussion started by: Loc
10 Replies

2. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

3. Shell Programming and Scripting

Convert TZ output to a different format

Friends, I am trying to convert my local server timezone EST to UTC and for which I used the TZ command, see below $ date Thu Dec 6 10:14:14 EST 2012 $ $ TZ=UTC date -d '10:14 EST' Thu Dec 6 15:14:00 UTC 2012 Now I would like to have the same output in 'yyyymmdd hh:mm' format. ... (4 Replies)
Discussion started by: vivek_damodaran
4 Replies

4. Shell Programming and Scripting

convert the output in table format

Hi All, I have a output like below values val1=test.com val2=10.26.208.11 val3=en1 val4=test-priv1.com val5=192.168.3.4 val6=en2 val7=test-priv2.com val8=192.168.4.4 val9=en3 val10=test-vip.com val11=10.26.208.9 val12=$val3 I want to convet this output values into below... (1 Reply)
Discussion started by: kamauv234
1 Replies

5. Shell Programming and Scripting

Help with convert string

Hi. I will be very appreciated for help. I need replace all characters into string with \ (backslash) I mean if I have word abcdefg as input. How I can convert it to \a\b\c\d\e\f\g Thanks and best regards. Staas. (5 Replies)
Discussion started by: beckss
5 Replies

6. Shell Programming and Scripting

convert timezone into human output

Hi I have a command which returns a timezone, Ej: root@bsades2: /usr/local/bin # lsuser -a time_last_login israel israel time_last_login=1279032223 Question: I want to parse this timezone '1279032223' into a 'martes, 13 de julio de 2010 16:43:43' from the ksh shell. Is itt possible? ... (3 Replies)
Discussion started by: iga3725
3 Replies

7. Shell Programming and Scripting

convert a column to row output?

Getting tired of cut-and-paste...so I thought I would post a question. how do I change this column output to a single row? from this: # vgdisplay -v /dev/vgeva05 | grep dsk | awk '{print $3}' /dev/dsk/c6t0d5 /dev/dsk/c11t0d5 /dev/dsk/c15t0d5 /dev/dsk/c18t0d5 /dev/dsk/c7t0d5... (8 Replies)
Discussion started by: mr_manny
8 Replies

8. Shell Programming and Scripting

awk: round output or delimit output of arithmatic string

I have a file with the following content. > cat /tmp/internetusage.txt 6709.296322 30000 2/7/2010 0.00I am using the following awk command to calculate a percentage from field 1 and 2 from the file. awk '{ print $1/$2*100 }' /tmp/internetusage.txt This outputs the value "22.3643" as a... (1 Reply)
Discussion started by: jelloir
1 Replies

9. UNIX for Dummies Questions & Answers

how to convert this file output

hi, How do I do this with sed and egrep? is that even possible? I have the following file with this content #OQ#||1|XDzb34_zcSETA|SETA #OQ#||3|XDzc24_zcSETA|SETA #OQ#||4|XDze12_zcSETA|SETA #OQ#||6|XDzf35_zcSETA|SETA #OQ#||7|ADzf38_zc|SETA 1. I want to strip out X and SETA... (5 Replies)
Discussion started by: jbchen
5 Replies

10. Shell Programming and Scripting

how to convert array into the string

Hi I have a line/string as follows: A=" 3498 NORDEA - INDX LINKED NORY" which was converted into an array of characters: p321$ echo "${ARR}" 3 4 9 8 N O R D E A - I N D X L I N K E D N O R Y When I am trying print this array there are blank... (4 Replies)
Discussion started by: aoussenko
4 Replies
Login or Register to Ask a Question