Want non-interpretation of blank space using cat

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Want non-interpretation of blank space using cat
# 1  
Old 08-22-2012
Want non-interpretation of blank space using cat

I have a file say ADCD which is like following-->

Please consider 'z' as space
#cat ADCD

Now I want to store the content of this file to a variable say VAR like this-->
#VAR=`cat ADCD`
#echo $VAR
<!--Yz|z--> <!--Nz-->

Now I don' t want the variable to evaluate space within the tags.

My Result should be like this-->
#echo $VAR
<!--Yzzz|z--> <!--Nzzzzz-->

Please help me on this. Thanks in advance.

Moderator's Comments:
Mod Comment Please view this code tag video for how to use code tags when posting code and data.

Last edited by vbe; 08-22-2012 at 09:09 AM.. Reason: code tags..
# 2  
Old 08-22-2012
use double quotes
echo "$var"

---------- Post updated at 01:43 PM ---------- Previous update was at 01:42 PM ----------

$ a=$(cat f.txt)
$ echo $a
<!--Y | --> <!--N -->
$ echo "$a"
<!--Y | -->
<!--N -->

# 3  
Old 08-22-2012
And instead of cat in command substitution, you could use the I/O redirector < for efficiency.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to add space in front of cat values?

Hi, Hope you are all doing fine. The problem today i faced during my coding was i wanted to add a space equals to a tab character in front of all the lines which i am cat using tee command. Main file contents mainfile ... (4 Replies)
Discussion started by: mad man
4 Replies

2. UNIX for Dummies Questions & Answers

Remove blank lines using cat command

plz help me to figure it out how i remove empty or blank files using cat command. i will be very thankful if u send me this answer... thanks (3 Replies)
Discussion started by: mushfiks1
3 Replies

3. Shell Programming and Scripting

Removing blank space using VI

Hi, How to remove blank spaces using vi (I am using AIX)? #cat siva.txt AAA BBB CCC DDD EEE FFF Need to remove space between 2 columns. Regards, Siva (7 Replies)
Discussion started by: ksgnathan
7 Replies

4. Shell Programming and Scripting

Not delete space blank

Hi everyone, i need to "grep" a file with a string with space blanks, like this: grep "XXXX XX" file.txt The problem, i need put the "XXXX XX" in a string variable. When the script executes the grep, do: gresp XXXX XX file.txt How can i solve this problem? The... (5 Replies)
Discussion started by: Xedrox
5 Replies

5. UNIX for Dummies Questions & Answers

blank space

hi everyone, i have a problem in unix script , i need to remove line that has blank , not blank line . example: mahm,,jdggkhsd,ghskj,,fshjkl can anyone help? (4 Replies)
Discussion started by: Reham.Donia
4 Replies

6. Shell Programming and Scripting

Cut last blank space

Hello, I am using this to get only directories : ls -l | grep '^d'and here is the result : drwx------ 13 so_nic sonic 13 Nov 4 13:03 GLARY drwx------ 3 so_nic sonic 3 May 6 2010 PSY2R drwx------ 15 so_nic sonic 15 Oct 14 08:47 PSYR1 But I only need to keep this... (7 Replies)
Discussion started by: Aswex
7 Replies

7. UNIX for Dummies Questions & Answers

No Space Message Interpretation

Hi, I get the message NOTICE HTFS :No Space on dev hd (1/104), What does (1/104) mean? Is there any link, I can get material on understanding unix message log? thanks. (4 Replies)
Discussion started by: scomrade
4 Replies

8. Shell Programming and Scripting

Cat Command and Blank Lines

Hi All, I was testing for blank lines and I want to use the cat command only for groupline in `cat /home/test/group` do if then echo "blank found" fi done I want to check if the current line read is a blank line. I have tested with $groupline="\n" ,... (11 Replies)
Discussion started by: datkan
11 Replies

9. Shell Programming and Scripting

Have a basic 'for i in cat list' - Trying to get i to be set to a name with a space

Hi Have a file called ldap.list: ****** "o=unix forum" o=groups ****** i wrote a basic script that runs: for i in `cat ldap.list` do ldapsearch -h host -p 389 -b $i THE PROBLEM: - It looks like when the for i in cat ldap.list runs, it doesn't seem to care about the " ", it... (2 Replies)
Discussion started by: littlefrog
2 Replies

10. Shell Programming and Scripting

append blank space

Hi, I would like to add blank space for fixed length(50) if length of string <30. Scenario: File Size AAA.CSV 123 BB.CSV 134 Expected: File Size AAA.CSV 123 BB.CSV 134 I want append blank space until 30 character. Thanks and Regards, HAA (1 Reply)
Discussion started by: HAA
1 Replies
Login or Register to Ask a Question

Featured Tech Videos