Вопрос

This takes a directory as a parameter:

#!/bin/bash

ls -l $1 |awk '$3!=$4{print $9}' 

Now what I need is to be able to do ANOTHER ls -l on the just the files that are found from the awk statement.

Yeah, it sounds dumb, and I know of like 3 other ways to do this, but not with awk.

Это было полезно?

Решение

#!/bin/bash

ls -l $1 | awk '$3!=$4{ system( "ls -l '$1'/" $9}' 

Другие советы

Use awk system command:

ls -l $1 |awk '$3!=$4{system("ls -l " $9)}'

The command to use is xargs.

man xargs

should give some clues.

If it is allowed to adjust the first ls -l you could try to do:

ls -ld "$1"/* |awk '$3!=$4{print $9}' | xargs ls -l

In this case ls will prefix the directory. But I don't know if this is portable behavior.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top