Thread: Script help

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    1
    Rep Power
    0

    Script help


    I need to make a unix script that takes a directory as a arguement, and then print out all of the files in that directory in 2 columns. -Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    137
    Rep Power
    0
    Although this looks a bit like homework to me, I'll be nice for once

    Code:
    #!/bin/bash
    INPUT="$1"
    ls -x ${INPUT}
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    India
    Posts
    61
    Rep Power
    11
    I think the question was to print file names in 2 not (to :-))
    columns. This script will do th printing in 2 columns

    #!/bin/sh
    j=0;

    for i in `ls -1 $1`
    do
    echo "$i \c"
    j=`expr $j + 1`
    k=`expr $j % 2`
    if [ $k -eq 0 ]
    then
    echo ""
    fi
    done
    Regards
    JK

IMN logo majestic logo threadwatch logo seochat tools logo