unixls

how to list files in Unix without the modified date


I'm trying to create a zip file that will run on multiple servers to compare the contents of the servers. For many reasons, the easiest and best piece of information for me to compare is a text file of the directory listings... but I need that without the modified date as they make the comparisons show differences that don't matter in this case.

So if I run command ls -la to create text output for comparing, I get would get something like this:

drwxr-xr-x.  6 root   root       4096 Mar 20 14:59 .
dr-xr-xr-x. 22 root   root       4096 Feb 18 03:20 ..
drwxr-xr-x.  9  web   ad         4096 Oct 30 14:35 apache-tomcat-6.0.18
drwxr-xr-x.  9  web   ad         4096 Mar 24 03:00 apache-tomcat-6.0.36
lrwxrwxrwx.  1 root   root          5 Oct 30 14:06 java -> java6
lrwxrwxrwx.  1 root   root         16 Oct 30 14:05 java6 -> jdk/jdk1.6.0_37/
lrwxrwxrwx.  1 root   root         16 Mar 20 14:59 java7 -> jdk/jdk1.7.0_17/
drwxr-xr-x.  4 root   root       4096 Mar 20 15:02 jdk
lrwxrwxrwx.  1 root   root         21 Nov  6 15:09 tomcat -> apache-tomcat-6.0.36/

What I would like is to use is ls -la | cut -c 1-31 but that only takes one list (the characters 1-31) and I really want the data after the date. I'm fairly new with Unix and was curious if anyone knows how to produce a list that would look something like this:

drwxr-xr-x.  6 root   root       4096 .
dr-xr-xr-x. 22 root   root       4096 ..
drwxr-xr-x.  9  web   ad         4096 apache-tomcat-6.0.18
drwxr-xr-x.  9  web   ad         4096 apache-tomcat-6.0.36
lrwxrwxrwx.  1 root   root          5 java -> java6
lrwxrwxrwx.  1 root   root         16 java6 -> jdk/jdk1.6.0_37/
lrwxrwxrwx.  1 root   root         16 java7 -> jdk/jdk1.7.0_17/
drwxr-xr-x.  4 root   root       4096 jdk
lrwxrwxrwx.  1 root   root         21 tomcat -> apache-tomcat-6.0.36/

Thanks


Solution

  • I think the best solution to your problem is to use awk.

    ls -la | awk '{print $1, $2, $3, $4, $5, $9}'
    

    So you obtain an output like this:

    drwxr-xr-x. 6 root root 4096 .
    dr-xr-xr-x. 22 root root 4096 ..
    drwx------+ 5 user staff 170 Desktop
    drwx------+ 16 user staff 544 Documents
    drwx------+ 6 user staff 204 Downloads