Results 1 to 2 of 2

Thread: Stringing file contents

  1. #1
    Member
    Join Date
    Jul 2011
    Posts
    92
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Rep Power
    3

    Default Stringing file contents

    Need to use budir=/root/BUinfo/BUDIR and use that variable to move contents of BUDIR into a space separated string.
    cat-ing is not being friendly so tried tail-ing but seems use of the variable is objectionable.
    Code:
    BUDIR contains:
    /xxx
    /yyy
    /zzz
    Interactively:
    budir=/root/BU_info/BUDIR
    cat $budir yields
    /xxx
    /yyy
    /zzz
    src=`echo $(cat $budir | column)`
    bash-4.1# echo $src
    /xxx /yyy /zzz  which is what I wanted.
    But shell script:
    #!/bin/sh
    budir=/root/BUinfo/BUDIR
    cat $budir
    src=`echo $(cat $budir | column)`
    echo $src
    yields: 
    /root/BUinfo/BUDIR: No such file or directory
    Suggestions/reasoning welcomed.
    Last edited by timtravlr; 25th March 2013 at 11:24 PM. Reason: added test

  2. #2
    Member
    Join Date
    Jul 2011
    Posts
    92
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Rep Power
    3

    Default Stringing file contents

    Finally resorted to while read line; do ; xxxxxxx; done < $budir.
    Should cat respond with:
    cat /root/BUinfo/BUDIR
    cat: /root/BUinfo/BUDIR: No such file or directory
    when executed from within /root/BUinfo and
    cat BUDIR responds with its contents ???

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Search contents in a file and create files accordingly
    By gsuwal in forum CentOS / RHEL / Fedora
    Replies: 2
    Last Post: 27th December 2012, 09:05 AM
  2. Replies: 7
    Last Post: 24th April 2012, 02:13 AM
  3. Use Bash for loop file contents
    By chinalinix in forum Shell scripting
    Replies: 6
    Last Post: 4th November 2011, 06:25 PM
  4. [Solved] Restoring tape contents
    By g_ramesh in forum Linux software
    Replies: 8
    Last Post: 18th October 2010, 04:41 PM
  5. contents of files
    By guest in forum Shell scripting
    Replies: 13
    Last Post: 13th September 2005, 07:41 AM

Posting Permissions

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