Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: copy literal string to a Linux file  (Read 8314 times)

0 Members and 1 Guest are viewing this topic.

BRIANH

    Topic Starter


    Rookie

    • Experience: Familiar
    • OS: Windows XP
    copy literal string to a Linux file
    « on: February 01, 2011, 11:05:17 AM »
    Using Linux I have a script which executes various programs e.g. netstat, ps -ef|grep ....   and directs the output to a common file. I've noticed that
    the output is strung together  i.e.  no separator between e.g. netstat and then another netstat. I'd like to insert a separator literal between them
    to make the viewing of the output file easier.. rather than try to determine where the output of one netstat ends and the next begins..

    Anyone have an idea  I've tried cp 'string' >> output file   but that failed with a syntax error....

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: copy literal string to a Linux file
    « Reply #1 on: February 01, 2011, 11:23:07 AM »
    try
    Code: [Select]
    echo 'string' >> output file
    I was trying to dereference Null Pointers before it was cool.

    BRIANH

      Topic Starter


      Rookie

      • Experience: Familiar
      • OS: Windows XP
      Re: copy literal string to a Linux file
      « Reply #2 on: February 01, 2011, 01:04:29 PM »
      I've tried -      cat 'string' >> /output file.                   It results in a syntax error  - no such file 'string'..

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: copy literal string to a Linux file
      « Reply #3 on: February 01, 2011, 01:47:03 PM »
      I've tried -      cat 'string' >> /output file.                   It results in a syntax error  - no such file 'string'..
      OK, any luck using echo as I suggested?
      I was trying to dereference Null Pointers before it was cool.

      ghostdog74



        Specialist

        Thanked: 27
        Re: copy literal string to a Linux file
        « Reply #4 on: February 01, 2011, 05:57:10 PM »
        I've tried -      cat 'string' >> /output file.                   It results in a syntax error  - no such file 'string'..
        cat does not work on strings. It works on files. Use echo or printf.
        But I suspect you are reading your output created in *nix on a windows program such as notepad?