Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2004
    Posts
    8

    Exclamation Unanswered: Clearing ocntents of file but retain permissions

    Is there a way to clear the contents of a file without removing any of the permissions?

    Currently I use the rm filename to removed the entire file but then I always have to go back in and rest the permissions.

    Can anyone help me with a script that will clear the contents but leave the permissions intact?


    Any help is greatly appreciated.

    Thanks in advance..
    Armando

  2. #2
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    > /path2file
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

  3. #3
    Join Date
    Jun 2004
    Posts
    20
    sed -e '/^/d' Inputfile >tempfile
    mv tempfile Inoutfile

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Code:
    echo /dev/null>/path2file
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  5. #5
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    Quote Originally Posted by LKBrwn_DBA
    Code:
    echo /dev/null>/path2file
    '/path2file' will containg '/dev/null'
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

  6. #6
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Thumbs down

    Ooops, yes, it should be cat instead of echo!
    Code:
     cat /dev/null>/path2file
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  7. #7
    Join Date
    Oct 2004
    Posts
    8
    Quote Originally Posted by LKBrwn_DBA
    Ooops, yes, it should be cat instead of echo!
    Code:
     cat /dev/null>/path2file
    I tried this and it still took the permissions from the file. Any other ideas?

  8. #8
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Question

    Quote Originally Posted by Armando Soto
    I tried this and it still took the permissions from the file. Any other ideas?
    Which operating system?
    I tested on Solaris and the permissions were not changed!
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

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