How to pipe command

Hi All,

I want to create a command that executes a text editor with the most recent file in the current current directory.

So a good start to achieve this is :

ls -lrt | cut -c55- | tail -1

which provides the name of the most recent file in a directory

The problem is to pipe the result of this command with the text editor command (suppose dtpad).

So my question is : does it exist a way to make something like

ls -lrt | cut -c55- | tail -1 | dtpad XXXX

where XXXX is a variable or a command to force the dtpad command to take as parameter the result of the pipe

Thanks by advance,
Nicolas.
France

You don't say what version of unix your on but try

dtpad `ls -lrt|cut -c55-|tail -1`

Use 'find' to obtain the most recent files.

Ex: 'find $YOUR_DIR -mtime -5' will provide files with last modified date of less than 5 days....

then use dtpad as suggested by kevin.

Cool that works...

The unix version I use is SunOS 5.5.1 (result of uname -sr)

Nicolas

here is an alternate way that doesn't depend on a certain length to cut from-to.

It may be easier for you, I know it is for me. Also, you can use this principle in scripting as well.

dtpad `ls -lrt | awk '{ print $NF }' | tail -1`

This captures the last field and also gets rid of and leading or trailing spaces as well.

BTW, the $NF will always pull the last field. This is especially good if you have a line with more than 9 delimited fields, because $0 will print the whole line with the "awk" command.

UNIX is so great, we can do the same things in some many different ways!

UNIX RULESSSSSS!!!!!!!!!

:wink: