This is a discussion on new scripting problem, cat | foreach within the Shell scripting forums, part of the Development/Scripting category; I've found another way to list my dirs and wants to check each dir with the du -khs command. I ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
I've found another way to list my dirs and wants to check each dir with the du -khs command.
I have all the directories in a file and wants to read the file and the perform the task for each of the dirs in it. the file consists of rows with dir names followed by / can I cat the file in my script and the perform a foreach loop on them? any suggestions? The output should be one logfile for each of the dirs |
| Sponsored Links | ||
|
|
|
|||
|
I've tried some different syntaxes and managed to perform the task like this:
Code:
for i in $(ls -p); do du -khs echo $i; echo $i; done > temp1 cat temp1 | grep ^[0-9] | grep /$ > temp2 Code:
5.6M bin/ 6.7M boot/ 168K dev/ 60M etc/ 597M home/ 8.0K initrd/ 89M lib/ 16K lost+found/ 16K media/ 8.0K misc/ 8.0K mnt/ 8.0K opt/ 899M proc/ 143M root/ 16M sbin/ 0 selinux/ 8.0K srv/ 0 sys/ 576K tmp/ 2.4G usr/ 138M var/ Code:
du: cannot access `echo': No such file or directory the next problem is that i want to specify a directory to go further down in and perform the same task, lets say i want to check the content of the home/ directories, how can i do this? My home directory catalogue structure is like this.. Code:
home/
group1/
user/
user1/
user2/
group2/
user/
user1/
user2/
can you give me som hints? |
|
||||
|
Quote:
Code:
LIST= $(find /home -type d) Code:
for d in $LIST; do du -ksh $d>>/tmp/list.txt; done Code:
less /tmp/list.txt |
|
|||
|
i just cant get it to work the way i want..
this is what it looks like at the moment Code:
home/
group1
backup
users///
group2
backup
users///
I happy that I went to the hairdresser the other day, otherwise I would be tearing my hair of! |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| perl scripting | pansarevai | Coding in General | 2 | 03-17-2008 06:34 PM |
| new to scripting | poone1 | Shell scripting | 0 | 01-15-2008 02:19 AM |
| need help on shell scripting | rahul_sayz | Shell scripting | 1 | 12-08-2007 11:37 AM |
| Books on Shell-Scripting | shankar100 | Shell scripting | 3 | 02-16-2007 02:19 PM |
| scripting | ganes | Shell scripting | 2 | 09-06-2005 01:04 PM |