Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add path's to output file. 1

Status
Not open for further replies.

Cimm

Technical User
Feb 17, 2005
69
US
I have an output I would like to add paths to.
My output looks like this now..

/usr/local/testing/directory/test1
0 Feb 16 12:07 hello
0 Feb 16 12:07 hello2
0 Feb 16 12:07 hello3
/usr/local/testing/directory/test2
0 Feb 16 14:52 bye
0 Feb 16 14:52 bye1
0 Feb 16 14:52 bye3
0 Feb 16 14:52 bye4

I want it to look like this
/usr/local/testing/directory/test1/hello
/usr/local/testing/directory/test1/hello2
/usr/local/testing/directory/test1/hello3
/usr/local/testing/directory/test2/bye
/usr/local/testing/directory/test2/bye1
....
....

Any idea's or advise how to solve it?
Thanks in advance
 
Code:
awk '{ if (/^\//) dir = $0; else print dir "/" $NF }'

. Mac for productivity
.. Linux for developement
... Windows for solitaire
 
Thanks for a reply, but I get errors

awk: syntax error near line 1
awk: illegal statement near line 1
awk: illegal statement near line 1

I executed it by
awk '{ if (/^\//) dir = $0; else print dir "/" $NF }' output

What do I do wrong?
 
Nada doing wrong, it should work...
a) try if ($0 ~ /^\//) ..
b) is that awk u use some old thing? try with n/m/gawk

. Mac for productivity
.. Linux for developement
... Windows for solitaire
 
ksh: n/m/gawk: not found

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
vlad, lol!

. Mac for productivity
.. Linux for developement
... Windows for solitaire
 
Does anyone know if it works to do the ftp command

get /path/path/path/something.log

without doing:
cd /path/path/path/
get something.log

 
Ever tried? (should work.. besides your client may wanna take the remote filename including path as local filename, helps to specify the filename as second argument)

. Mac for productivity
.. Linux for developement
... Windows for solitaire
 
I did try, thats why I asked.
But yes, you are right, it do need a second argument for local filename.

get /path/path/path/something.log something.log
--- works

get /path/path/path/something.log
--- Doesnt work

Thanks again..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top