Results 1 to 6 of 6

Thread: 2 Small scripts

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default 2 Small scripts

    Im not sure if someone can help me but im trying to create a litte script that processes the output of the ls /dev command. For each value returned by this command the script must determine if a filename represents a character-special file, a block-special file, or neither.y brother says this is not possible but i dont think so can someone help me please ?
    m
    Last edited by juankykong; 17th November 2011 at 09:23 AM.

  2. #2
    Senior Member
    Join Date
    Aug 2011
    Posts
    458
    Thanks
    0
    Thanked 62 Times in 58 Posts
    Rep Power
    10

    Default

    Hi,

    at least bash can do it (please don't use ls).

    see help test, test's file operators.
    Last edited by Watael; 17th November 2011 at 09:52 AM.

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default tried

    I've tried bash but i dont seem to be able to make it happen can someone perhaps let me know what to code?

  4. #4
    Junior Member
    Join Date
    Jun 2011
    Location
    Pune
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Hi,
    Try this
    Code:
     ls -lh | grep ^whatever character you want 
                   ls -lh | grep ^c(character)



    Regards,
    linpen.

  5. #5
    Senior Member
    Join Date
    Aug 2011
    Posts
    458
    Thanks
    0
    Thanked 62 Times in 58 Posts
    Rep Power
    10

    Default

    Code:
    for file in /dev/*
    do test -b "$file" && type=block
       test -c "$file" && type=character
       if test -n "$type"
       then printf '%s is %s file\n' "$file" "$type"
            unset type
       fi
    done
    or something like
    Code:
    file /dev/* | grep '  *\(block\|character\)'

  6. #6
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default Thanks! :)

    i apprecciate your help!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. small error in shellscripting
    By aish in forum Shell scripting
    Replies: 4
    Last Post: 14th October 2011, 09:07 PM
  2. how to become a small public internet DNS supllier?
    By IsraelQuality in forum Domain Name Server
    Replies: 4
    Last Post: 9th November 2010, 04:28 PM
  3. Small Issue : please help resolvinig it
    By ermunishanand in forum Shell scripting
    Replies: 1
    Last Post: 11th October 2008, 02:54 AM
  4. Change /tmp path on KDE as it is too small for KDE
    By marccarter0 in forum Ubuntu / Debian
    Replies: 2
    Last Post: 26th May 2008, 10:34 PM
  5. Small handy one liners
    By digen in forum Getting started tutorials
    Replies: 0
    Last Post: 7th February 2007, 04:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •