Getting output from a file similar to cat output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting output from a file similar to cat output
# 1  
Old 11-26-2013
Getting output from a file similar to cat output

I have a file

Code:
# cat /root/llll
11
22
33
44

When I cat this file content to a variable inside a shell script and echo that shell script, it does not show up as separate lines. I need echo output similar to cat.

Code:
cat /root/shell_script.sh
#!/bin/bash

var=`cat /root/llll`
echo $var

Code:
# sh /root/shell_script.sh
11 22 33 44

# 2  
Old 11-26-2013
Change:
Code:
echo $var

to:
Code:
echo "$var"

This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 11-26-2013
Thanks Don
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh cat file output into a file on local computer

Hello, I'm on a remote computer by SSH. How can I get the output of "cat file" into a file on the local computer? I cannot use scp, because it's blocked. something like: ssh root@remote_maschine "cat /file" > /locale_machine/file :rolleyes: (2 Replies)
Discussion started by: borsti007
2 Replies

2. UNIX for Dummies Questions & Answers

Cat Input & Output to a Log file

Team, we use below command to store the contents in a logfile. cat a.txt > a.log a.txt content is 123 345 Is there any options available to store the command used also? for eg a.log may show as cat a.txt 123 345 (5 Replies)
Discussion started by: sid2013
5 Replies

3. Shell Programming and Scripting

Cat writing only one record in the output file

Hi All, I have an input file containing data as below: Input.DAT XXXXXXX|YYYYYYY|ZZZZZZZZZZ|12334446456|B|YY|111111111|111111111|111111111|111111111|15|3|NNNNNN|Y|3|AAA|111111111... (11 Replies)
Discussion started by: sagar.cumar
11 Replies

4. UNIX for Dummies Questions & Answers

Cat command drops lines in output file

I use the cat command to concatenate text files, but one of the rows I was expecting doesn't display in the output file. Is there a verbose mode\logging mechanism for the cat command to help me investigate where the lines I was expecting are going?? cat 7760-001_1_*_06_*.txt | grep -v... (1 Reply)
Discussion started by: Xin Xin
1 Replies

5. Shell Programming and Scripting

Cat piped output

Hello, How can I efficiently cat piped output with another file? > (awk command) | cat file1 (piped output) Thanks! (11 Replies)
Discussion started by: palex
11 Replies

6. UNIX for Advanced & Expert Users

inconsistent cat output

Hi I'm executing a menu script in which I `cat a file` but it's giving different output some times. Following is the code fragment taken from my script. while true do cat procs.configured echo ---------separator-------------- sleep 3 done when I execute this code fragment, `cat` outputs... (2 Replies)
Discussion started by: axes
2 Replies

7. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

8. Shell Programming and Scripting

cat and output filename

Hi, how I can display a file with cat and printing the filename before each line. e.g. file1 { one two three four five } Output: file1:one file2:two file1:three file1:four file1:five (12 Replies)
Discussion started by: Timmää
12 Replies

9. Shell Programming and Scripting

cat file and parse output

Hello, I'm new to shell scripting and did a search on the forum to what I want to do but couldn't find anything. I have about 9 routers that outputs to 1 syslog file daily named cisco.year.mo.date.log ex: cisco.2009.05.11.log My goal is to make a parsing script that cats today's syslog... (2 Replies)
Discussion started by: jjrambar
2 Replies

10. UNIX for Dummies Questions & Answers

unix cat gives no output

hi, i searched the forum, but found no thread relate to this; so sorry if it's duplicated. I'm using unix cat command but it gives no output. I check permission, owner and group; all of which are OK. I could do less and vi. any suggestions? thanks, (2 Replies)
Discussion started by: notvwatcher
2 Replies
Login or Register to Ask a Question