The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 02-05-2008
MaestroRage MaestroRage is offline
Registered User
 

Join Date: Feb 2008
Posts: 16
Using a variable inside a file to cat another.

I have a question to do and it's somewhat confusing. It says, and I quote

"Create a file called file_1 with three lines of text in it. Create a shell variable called "f_name", assign it the string "file_1". Use the cat command and the variable "f_name" to display the contents of the file "file_1""

Now what I did was I made both files, and in "f_name" I wrote this.

#!/bin/sh
f_name="file_1"
cat $f_name

and this will work. However what I think is the professor wants me to use this shell scripts f_name variable in a cat command without having the script itself do the work.

Is there a way to do this?
Reply With Quote
Forum Sponsor