help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Sed/awk question (plus ca. 2006 Chuck Norris jokes)


From: Matthew Cengia
Subject: Re: [Help-bash] Sed/awk question (plus ca. 2006 Chuck Norris jokes)
Date: Wed, 16 Jul 2014 11:02:39 +1000
User-agent: Mutt/1.5.21 (2010-09-15)

On 2014-07-15 18:24, Bill Dorrian wrote:
> I'm working on an awk/grep/sed problem. Is there one line of BASH
> code would I use to make the two "chucknorris" $output variables
> into the statements below them? Note that the comma-delimited list
> can be between one and ten items long, so it would have to
> compensate for that somehow. Also, note the addition of
> "@chucknorris" and "man" to the beginning and end of each line.
> 
> *From the first machine:*
> 
> $output=`ssh server1 cat /etc/chuck.txt`
> 
> *Actual output: *
> 
> swims through land
> 
> *Desired output:*
> 
> @chucknorris (swims,,) (through,,) (land,,) (man,,)

Try this:

  echo swims through land > chuck.txt
  words=($(cat chuck.txt))
  printf '@chucknorris'; printf ' (%s,,)' "address@hidden" man
  echo

@chucknorris (swims,,) (through,,) (land,,) (man,,)

-- 
Regards,
Matthew Cengia

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]