2014-01-29 4 views
0

Напишите программу-оболочку, которая следует алгоритму ниже, чтобы получить длинный список всех каталогов, имена которых заканчиваются 3-символьным расширением, и чьи разрешения rwx для пользователя (владельца).Написание программы оболочки stdout

ALGORITHM: 
1. Do the same ls command you used in question 2 above, except REDIRECT 
    the ls command's stdout to go into a file named tempFile (instead of 
    the monitor). 
2. Use grep to filter the lines of tempFile so that a line is kept ONLY 
    if it corresponds to a DIRECTORY that has rwx permissions for its 
    user (owner). 
3. delete (remove) tempFile 

Im застрял на 1 я до сих пор:

Ls -ld * ???. > TempFile

+1

Почему не то, что у вас есть работа? –

+0

Кроме того, FIE на тех, кто придумал шаг 2. –

+0

это работает, но idk, что я должен сделать для шага 2 – user3250769

ответ

0

Это работает для меня:

#! /bin/bash 

ls -ld * > tmp # get a list of the permissions of all directorys in this folder and write it to the tmp file 
grep "^drwx" tmp # filter the tmp files for lines beginning with drwx 
rm tmp   # remove the file tmp 
Смежные вопросы