Hello,
I have two problems with making a shell script.
1- If with a 'ls -lia' I got, for exampl, this result:
Code:
98487 -rw-r--r-- 1 me me 2 Nov 5 12:59 prova1
100458 -rw-r--r-- 1 me me 2 Nov 5 12:59 prova2
100460 -rw-r--r-- 1 me me 2 Nov 5 12:59 prova3
98616 -rw-r--r-- 1 me me 2 Nov 5 12:59 prova4
98617 -rw-r--r-- 1 me me 2 Nov 5 12:59 prova5
then, if I make in a shell script a
Code:
for abc in `ls -lia`
do .....
the value of abc first is '98487', then '-rw-r--r--', then '1', then 'me'....
Is it possible to make a 'for' storing in abc a whole line each time (first 98487 -rw-r--r-- 1 me me 2 Nov 5 12:59 prova1 , then 100458 -rw-r--r-- 1 me me 2 Nov 5 12:59 prova2 .... ) ?
2- The second question is a problem with cut: I have already red the cut man pages but I can't find anything to select from 'ls -lia' only one column (for example the protections). 'ls -lia | cut -f1 -d\ ' doesn't work, it returns 100458 and 100460 for the first column; 98487, -rw-r--r--,-rw-r--r--,98616,98617 for the second .... I could make 'ls -lia | cut -b1,2,3,4,5,6' to select the first column, but this only works if I know how large it is. If I wanted to select, for example, the name column I don't know if it is from -b22 to 28 or -b50 to 100....
Thx for help