1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Unix 'read' command

Discussion in 'Scripting & Programming' started by Ndidi, Jan 31, 2009.

  1. Ndidi

    Ndidi New Member

    4
    0
    1
    I'm pretty new to Unix and trying to familiarise myself with it.

    When using read on a string of text, the first word is assigned $1, the second $2 and so on.

    I've used the manual pages but cant find how to assign the entire text as $1.

    Any tips/cheats/codes/hints will be truly appreciated!!!
     
  2. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    Er - there is some detail missing there - read will normally read the whole line, and putting the results in $1 etc is a new one on me.

    Usually
    Code:
     read myline 
    will do what you want, so what does your code actually look like? And which shell are you using?

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  3. dwhyte85

    dwhyte85 Nibble Poster

    54
    1
    39
    Check the IFS's (internal field separators) - I remember having problems at uni with this!
     
    Certifications: Bsc. Comp Sci, MCP, MCTS, MCSA, CCENT, MBCS
    WIP: ICND 2, CEH and converting MCSA to MCITP: Enterprise Administrator

Share This Page

Loading...