cat and export


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers cat and export
# 1  
Old 02-27-2009
cat and export

I have a file named filelist. the content is a list of files including the path.

$ cat filelist
$curdir/test1
$curdir/test2

I want to cat each file in the list, such as cat $curdir/test1, cat $curdir/test2. (The $curdir has been exported).

it can't open the test1/test2, it can't change $curdir to /home/steven/curdir in script, but I can run it on command line.

313$ cat $curdir/test
dfsfdfdsdffsfest
314$ cat `head -1 filelist`
cat: cannot open $curdir/test
315$ head -1 filelist
$curdir/test
316$

how to export the $curdir, so that cat can get it?
# 2  
Old 02-27-2009
Perhaps...

Code:
#!/bin/sh

TESTDIR=/var/tmp
export TESTDIR

file=`cat $TESTDIR/filelist`
for i in $file 
do
    cat $i
done

# 3  
Old 02-27-2009
Thanks your reply
what's the content of your $TESTDIR/filelist?

I mean the file $TESTDIR/filelist also include some relative path.

such as (all realtvie path are set in .profile)

$TESTDIR/test1
$TESTDIR/test2
$TESTDIR2/test3
# 4  
Old 02-27-2009
I just had /var/tmp/test1 and /var/tmp/test2 in my /var/tmp/filelist file.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Ubuntu

How use export

Hello, I'm trying to use export for non use "./" when I execute a program. I mean "program" in place of "./program" I tried this: export doit=program But doesn't work the answer is: doit command not found Then, I see the variables using export, and I can see: ... (1 Reply)
Discussion started by: NewBe
1 Replies

2. Shell Programming and Scripting

export. I know it, but...

Hello, I have the following command at the "Shell": export PATH=${PATH}:${ANT_HOME}/bin I know what "export" does and the ANT_HOME part. But, regarding the following part: ${PATH} What is "PATH" Supposed to be here. In other words, what is the value of "PATH". As far as for... (4 Replies)
Discussion started by: SWEngineer
4 Replies

3. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

4. Shell Programming and Scripting

for i in `cat myname.txt` && for y in `cat yourname.txt`

cat myname.txt John Doe I John Doe II John Doe III ----------------------------------------------------------------------- for i in `cat myname.txt` do echo This is my name: $i >> thi.is.my.name.txt done ----------------------------------------------------------------------- cat... (1 Reply)
Discussion started by: danimad
1 Replies

5. Shell Programming and Scripting

About export

Hi all, I am calling a script from main script. The called script (second script) have to return some value, i can use exit to pass but in exit i have to pass some other value. i used "export Var", but this command resides in a function of second script. could you please tell me how to... (3 Replies)
Discussion started by: Arunprasad
3 Replies

6. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

7. BSD

How to export

Hi I need to export some directpry path like below: var1=/<>/<>/<> export var1 This is my basic idea. I tried export var1=/<>/<>/<> after executing this in a shell i did an echo of the var1. But nothing happened. Can you please help me with this. I need to srite a script to... (4 Replies)
Discussion started by: jisha
4 Replies

8. Shell Programming and Scripting

export???

I am trying to export the variable OBJ2 and set it to done. Can some one please let me how to do this? I have tried editing my .bashrc file with this echo <VARIABLE_NAME>=<"OBJ2"> But that wont seem to work... (1 Reply)
Discussion started by: Justinkase
1 Replies

9. Programming

export-dynamic

I load some dynamic libraries from main module (with dlopen). These libraries use 1 function from main module, therefore in Makefile I must use gcc -g -Wl,--export-dynamic,-rpath,./lib -o not not.o db.o -ldl -ldb -lpcap Note option --export-dynamic that is passed to the ELF linker. The... (4 Replies)
Discussion started by: Hitori
4 Replies
Login or Register to Ask a Question