Preserving space during command substitution


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Preserving space during command substitution
# 1  
Old 10-04-2005
Preserving space during command substitution

Hi all,

I am caught up in a problem .... tried all possible ways i knew .. but ended up in big zero ... ;-(

I have a file as below ..

$ cat siv.txt
1234567890BF00522000095ibsadministrator@ae.ge.com ibsadministrator@ae.ge.com

Note the spaces in between .... I am doing a cut on this ..

$ head -1 siv.txt | cut -c 11-
BF00522000095ibsadministrator@ae.ge.com ibsadministrator@

The spaces are preserved ... Well and good till here ...
But I need to assign this output to a variable and still preserve the spaces in the output which I am not able to do ..

$ bt=`head -1 siv.txt | cut -c 11-`
$ echo $bt
BF00522000095ibsadministrator@ae.ge.com ibsadministrator@

The spaces get truncated ...

Pls help me here...

Thanks in advance,

SNS
# 2  
Old 10-04-2005
How about
Code:
echo "$bt"

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regarding command substitution

Oracle Linux 5.6, 64-bit Given the following snippet wrkvar=`sqlplus -s / as sysdba <<EOF set echo off feedback off head off trimsp on select count(*) from v\$parameter where name in ('db_file_name_convert','log_file_name_convert') and value is not null; EOF` echo wrkvar=$wrkvarProduces... (2 Replies)
Discussion started by: edstevens
2 Replies

2. UNIX for Dummies Questions & Answers

Preserving the format of top command result

hi, I have tried the below command in RHEL5: top|mailx -s "test" "abc@cvf.com" But in the mail the content was not in proper format. Is there any way to preserve the format ? Thanks (2 Replies)
Discussion started by: pandeesh
2 Replies

3. Shell Programming and Scripting

Command substitution in echo

a=1 b1=unix echo $b`$a` The above code is not working. Instead of printing the variable b1 using 'echo $b1', how to use variable 'a' to print 'b1' (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

4. Shell Programming and Scripting

Preserving newlines when writing loops on the command line in bash

Dear All, I have a question that's been difficult to get an answer to. I often write command line loops, e.g. find files, print name, grep for term, apply sed, etc I use both zsh and bash. When I write a loop e.g. for line in `more myfile.txt` > do > echo $line > done but... (2 Replies)
Discussion started by: JohnK1
2 Replies

5. UNIX for Dummies Questions & Answers

read command - using output from command substitution

Hey, guys! Trying to research this is such a pain since the read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword. :eek: So, I wanted to use a command statement similar to the following. This is kinda taken... (2 Replies)
Discussion started by: ProGrammar
2 Replies

6. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

7. UNIX for Dummies Questions & Answers

Command substitution within an echo

I'm trying to get this to work and I'm not really sure how to do it. echo $x | awk '{print $NF}' MODIFIEDThe output I'm trying to get should look like: dir1 MODIFIED Where dir1 will be the result of: $x |awk '{print $NF}'I'm sure there's something I'm supposed to put around that part... (3 Replies)
Discussion started by: ewoods
3 Replies

8. Shell Programming and Scripting

injecting new line in sed substitution (hold space)

Morning, people! I'd like to call upon your expertise again, this time for a sed endeavor. I've already searched around the forums, didn't find anything that helped yet. background: Solaris 9.x, it's a closed system and there are restrictions to what is portable to it. So let's assume I... (4 Replies)
Discussion started by: ProGrammar
4 Replies

9. Shell Programming and Scripting

Difference between "Command substitution" and "Process substitution"

Hi, What is the actual difference between these two? Why the following code works for process substitution and fails for command substitution? while IFS= read -r line; do echo $line; done < <(cat file)executes successfully and display the contents of the file But, while IFS='\n' read -r... (3 Replies)
Discussion started by: royalibrahim
3 Replies

10. Shell Programming and Scripting

Substitution of last command

"Is there any substituation of last command or script syntax which can be used as a user. As far I know the "last" command is being used to display information about previous logins. A member of adm group or the user adm can execute it only. Thanks in advance for your usual help. Ghazi (6 Replies)
Discussion started by: ghazi
6 Replies
Login or Register to Ask a Question