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

Author Topic: Reg. unix command  (Read 3876 times)

0 Members and 1 Guest are viewing this topic.

csreekanthreddy508

    Topic Starter


    Starter

    • Experience: Beginner
    • OS: Unknown
    Reg. unix command
    « on: December 21, 2010, 04:04:44 AM »
    Hi Friends,

          I want to assign the ouput of sed followed by cut command to a variable.I am using the syntax as follows.


               a=`sed -n "1p" filename | cut -c1-30`
              echo $a

             Please help me regarding this.

    Thanks in advance
    sreekanth

    ghostdog74



      Specialist

      Thanked: 27
      Re: Reg. unix command
      « Reply #1 on: December 24, 2010, 07:05:09 PM »
      you don't need to use 2 tools to get the first 30 characters. use head

      Code: [Select]
      a=$(head -c30 file)
      echo $a