Ticket #2594: lsl.sh

File lsl.sh, 715 bytes (added by guido, 8 years ago)
Line 
1#!/bin/bash
2
3LS=(
4'drwxrwxrwt  5 root root 4096 Aug 18 09:19 .'
5'drwxr-xr-x 17 root root 4096 Aug 17 10:49 ..'
6'-rw-r--r--  1 536  536  4001599488 Aug 01 15:52
7 KNOPPIX_V6.7.0DVD-2011-08-01-EN.iso'
8'-rw-r--r--  1 536  536  70 Aug 01 20:06
9 KNOPPIX_V6.7.0DVD-2011-08-01-EN.iso.md5'
10'-rw-r--r--  1 536  536  385468 Aug 02 19:38 packages-dvd.txt'
11)
12
13echo "Output from some ls -l; fields are NOT aligned"
14for (( L=0 ; L<6 ; L++ ))
15        do
16                LINE=${LS[L]}
17                echo $LINE
18        done
19
20echo "Line parsed into an array; element 8 is file name"
21for (( L=0 ; L<6 ; L++ ))
22        do
23                LINE=( ${LS[L]} )
24                LINEARRAY=( $LINE )
25                FILENAME=${LINE[8]} #element numbers start at 0
26                echo $FILENAME
27        done
28echo "Note that there is now NO white space."