public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] [OT] Bash scripting
@ 2005-11-11 13:56 Peper
  2005-11-11 14:12 ` [gentoo-user] " Peper
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Peper @ 2005-11-11 13:56 UTC (permalink / raw
  To: gentoo-user

Hello,
I have a var $blah=' `pwd`/blah ' (extra spaces for clearer reading), how can 
i change it to 'output of pwd/blah' ?

-- 
Best Regards,
Peper
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [gentoo-user] Re: [OT] Bash scripting
  2005-11-11 13:56 [gentoo-user] [OT] Bash scripting Peper
@ 2005-11-11 14:12 ` Peper
  2005-11-11 14:19   ` Stoian Ivanov
                     ` (4 more replies)
  2005-11-11 14:14 ` [gentoo-user] " David Eduardo Gómez Noguera
                   ` (4 subsequent siblings)
  5 siblings, 5 replies; 16+ messages in thread
From: Peper @ 2005-11-11 14:12 UTC (permalink / raw
  To: gentoo-user

And one more thing, is there any smarter way to read one line of file then
head -n x file|tail -n 1 ?

-- 
Best Regards,
Peper
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] [OT] Bash scripting
  2005-11-11 13:56 [gentoo-user] [OT] Bash scripting Peper
  2005-11-11 14:12 ` [gentoo-user] " Peper
@ 2005-11-11 14:14 ` David Eduardo Gómez Noguera
  2005-11-11 14:30   ` [gentoo-user] " Peper
  2005-11-11 14:17 ` [gentoo-user] " Stoian Ivanov
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: David Eduardo Gómez Noguera @ 2005-11-11 14:14 UTC (permalink / raw
  To: gentoo-user

On Fri, 2005-11-11 at 14:56 +0100, Peper wrote:
> Hello,
> I have a var $blah=' `pwd`/blah ' (extra spaces for clearer reading), how can 
> i change it to 'output of pwd/blah' ?
> 

try
blah=`pwd`'/blah'

*Note the single quotes do not enclose `pwd`

-- 
David Eduardo Gómez Noguera <davidgn@servidor.unam.mx>

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] [OT] Bash scripting
  2005-11-11 13:56 [gentoo-user] [OT] Bash scripting Peper
  2005-11-11 14:12 ` [gentoo-user] " Peper
  2005-11-11 14:14 ` [gentoo-user] " David Eduardo Gómez Noguera
@ 2005-11-11 14:17 ` Stoian Ivanov
  2005-11-11 14:18 ` Jonathan Wright
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Stoian Ivanov @ 2005-11-11 14:17 UTC (permalink / raw
  To: gentoo-user

On Friday 11 November 2005 15:56, Peper wrote:
> Hello,
> I have a var $blah=' `pwd`/blah ' (extra spaces for clearer reading), how
> can i change it to 'output of pwd/blah' ?
>
> --
> Best Regards,
> Peper
sdr@sdr ~ $ echo "`pwd`/blah"
/home/sdr/blah
sdr@sdr ~ $
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] [OT] Bash scripting
  2005-11-11 13:56 [gentoo-user] [OT] Bash scripting Peper
                   ` (2 preceding siblings ...)
  2005-11-11 14:17 ` [gentoo-user] " Stoian Ivanov
@ 2005-11-11 14:18 ` Jonathan Wright
  2005-11-11 14:20 ` Allan Spagnol Comar
  2005-11-11 14:22 ` Matthias Guede
  5 siblings, 0 replies; 16+ messages in thread
From: Jonathan Wright @ 2005-11-11 14:18 UTC (permalink / raw
  To: gentoo-user

Peper wrote:
> Hello,
> I have a var $blah=' `pwd`/blah ' (extra spaces for clearer reading), how can 
> i change it to 'output of pwd/blah' ?

What do you mean - are you looking for the actual phrase 'output of 
/path/to/blah', i.e.

$blah='output of $(pwd)/blah'

are are you looking for program output:

$blah=$(./blah)

or

$blah=$($(pwd)/blah))

or are you looking for directory listings?:

$blah=$(ls $(pwd)/blah))

??

-- 
  Jonathan Wright
   ~ mail@djnauk.co.uk
   ~ www.djnauk.co.uk
--
  2.6.13-gentoo-r3-djnauk-b2 AMD Athlon(tm) XP 2100+
  up 4 days, 14:09, 1 user, load average: 0.80, 0.72, 0.56
--
  cat /dev/random (because u never know, u may see something u like)
--
  "Girls who put out are tramps. Girls who don't are ladies. This is,
  however, a rather archaic usage of the word. Should one of you boys
  happen upon a girl  who  doesn't  put  out,  do  not  jump  to  the
  conclusion that you have found a lady. What you have probably found
  is a Lesbian."

                                                      ~ Fran Lebowitz
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] Re: [OT] Bash scripting
  2005-11-11 14:12 ` [gentoo-user] " Peper
@ 2005-11-11 14:19   ` Stoian Ivanov
  2005-11-11 15:32   ` Etaoin Shrdlu
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Stoian Ivanov @ 2005-11-11 14:19 UTC (permalink / raw
  To: gentoo-user

On Friday 11 November 2005 16:12, Peper wrote:
> And one more thing, is there any smarter way to read one line of file then
> head -n x file|tail -n 1 ?
>
> --
> Best Regards,
> Peper


awk is your friend 
bash's read  is your friend
google is your friend
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] [OT] Bash scripting
  2005-11-11 13:56 [gentoo-user] [OT] Bash scripting Peper
                   ` (3 preceding siblings ...)
  2005-11-11 14:18 ` Jonathan Wright
@ 2005-11-11 14:20 ` Allan Spagnol Comar
  2005-11-11 14:22 ` Matthias Guede
  5 siblings, 0 replies; 16+ messages in thread
From: Allan Spagnol Comar @ 2005-11-11 14:20 UTC (permalink / raw
  To: gentoo-user

#!/bin/sh
#

blah=`pwd`/blah

echo $blah

output:

/home/thor/tmp/blah

holpe it helps.
On 11/11/05, Peper <peper@aster.pl> wrote:
> Hello,
> I have a var $blah=' `pwd`/blah ' (extra spaces for clearer reading), how can
> i change it to 'output of pwd/blah' ?
>
> --
> Best Regards,
> Peper
> --
> gentoo-user@gentoo.org mailing list
>
>


--
An application asked:
"Requeires Windows 9x, NT4 or better",
so I´ve installed Linux

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] [OT] Bash scripting
  2005-11-11 13:56 [gentoo-user] [OT] Bash scripting Peper
                   ` (4 preceding siblings ...)
  2005-11-11 14:20 ` Allan Spagnol Comar
@ 2005-11-11 14:22 ` Matthias Guede
  5 siblings, 0 replies; 16+ messages in thread
From: Matthias Guede @ 2005-11-11 14:22 UTC (permalink / raw
  To: gentoo-user

Peper wrote:
> Hello,
> I have a var $blah=' `pwd`/blah ' (extra spaces for clearer reading), how can 
> i change it to 'output of pwd/blah' ?

I'm not quiet sure what you mean with "output of pwd/blah".

If you want to assign "/home/me/blah" (or whatever your current 
directory is) you may use the environemnt variable $PWD and the 
expression would read as:
			
			blah=${PWD}/blah

If you insist to use the comand pwd you may write:
	
  	 	blah=`pwd`/blah or blah=$(pwd)/bla

If you want to assign the content of /home/me/blah to your variable use cat:
		
	     blah=`cat ${PWD}/blah` or blah=$(cat ${PWD}/blah)

Matthias

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [gentoo-user] Re: [OT] Bash scripting
  2005-11-11 14:14 ` [gentoo-user] " David Eduardo Gómez Noguera
@ 2005-11-11 14:30   ` Peper
  2005-11-11 16:34     ` davidgn
  0 siblings, 1 reply; 16+ messages in thread
From: Peper @ 2005-11-11 14:30 UTC (permalink / raw
  To: gentoo-user

> try
> blah=`pwd`'/blah'
>
> *Note the single quotes do not enclose `pwd`

I know how to use `command`, but the problem is that i read blah from file.
blah=`head -n x file|tail -n 1` and in the file i have lines `pwd`/blah. 
$ echo $blah
`pwd`/blah

This is the problem. 

-- 
Best Regards,
Peper
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] Re: [OT] Bash scripting
  2005-11-11 14:12 ` [gentoo-user] " Peper
  2005-11-11 14:19   ` Stoian Ivanov
@ 2005-11-11 15:32   ` Etaoin Shrdlu
  2005-11-11 15:45     ` Peper
  2005-11-11 20:49   ` Alexander Skwar
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Etaoin Shrdlu @ 2005-11-11 15:32 UTC (permalink / raw
  To: gentoo-user

On Friday 11 November 2005 15:12, Peper wrote:

> And one more thing, is there any smarter way to read one line of file
> then head -n x file|tail -n 1 ?

sed -n -e '12p' file.txt

prints the 12th line of "file.txt"
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [gentoo-user] Re: [OT] Bash scripting
  2005-11-11 15:32   ` Etaoin Shrdlu
@ 2005-11-11 15:45     ` Peper
  0 siblings, 0 replies; 16+ messages in thread
From: Peper @ 2005-11-11 15:45 UTC (permalink / raw
  To: gentoo-user

> > And one more thing, is there any smarter way to read one line of file
> > then head -n x file|tail -n 1 ?
>
> sed -n -e '12p' file.txt
>
> prints the 12th line of "file.txt"

Many thanks for that.

-- 
Best Regards,
Peper
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] Re: [OT] Bash scripting
  2005-11-11 14:30   ` [gentoo-user] " Peper
@ 2005-11-11 16:34     ` davidgn
  2005-11-11 16:58       ` Peper
  0 siblings, 1 reply; 16+ messages in thread
From: davidgn @ 2005-11-11 16:34 UTC (permalink / raw
  To: gentoo-user

Quoting Peper <peper@aster.pl>:

> > try
> > blah=`pwd`'/blah'
> >
> > *Note the single quotes do not enclose `pwd`
> 
> I know how to use `command`, but the problem is that i read blah from
> file.
> blah=`head -n x file|tail -n 1` and in the file i have lines `pwd`/blah.
> 
> $ echo $blah
> `pwd`/blah
> 
> This is the problem. 
> 

try with eval then:


dabicho@localhost ~ $ a='`pwd`/Ranma'
dabicho@localhost ~ $ echo $a
`pwd`/Ranma
dabicho@localhost ~ $  eval cd $a
dabicho@localhost ~/Ranma $ pwd
/home/dabicho/Ranma
dabicho@localhost ~/Ranma $ cd -
/home/dabicho
dabicho@localhost ~ $ eval echo $a
/home/dabicho/Ranma

hope that helps


-------------------------------------------------
www.correo.unam.mx
UNAMonos Comunicándonos

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [gentoo-user] Re: [OT] Bash scripting
  2005-11-11 16:34     ` davidgn
@ 2005-11-11 16:58       ` Peper
  0 siblings, 0 replies; 16+ messages in thread
From: Peper @ 2005-11-11 16:58 UTC (permalink / raw
  To: gentoo-user

> try with eval then:
Many thanks! I'd tried it before, but you showed me how to use it in proper 
way.

-- 
Best Regards,
Peper
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] Re: [OT] Bash scripting
  2005-11-11 14:12 ` [gentoo-user] " Peper
  2005-11-11 14:19   ` Stoian Ivanov
  2005-11-11 15:32   ` Etaoin Shrdlu
@ 2005-11-11 20:49   ` Alexander Skwar
  2005-11-11 20:51   ` Billy Holmes
  2005-11-12  1:22   ` Stroller
  4 siblings, 0 replies; 16+ messages in thread
From: Alexander Skwar @ 2005-11-11 20:49 UTC (permalink / raw
  To: gentoo-user

Peper schrieb:
> And one more thing, is there any smarter way to read one line of file then
> head -n x file|tail -n 1 ?

sed.

http://sed.sourceforge.net/sed1line.txt

|[...]
| SELECTIVE PRINTING OF CERTAIN LINES:
|[...]


 # print line number 52
 sed -n '52p'                 # method 1
 sed '52!d'                   # method 2
 sed '52q;d'                  # method 3, efficient on large files


-- 
Alexander Skwar
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] Re: [OT] Bash scripting
  2005-11-11 14:12 ` [gentoo-user] " Peper
                     ` (2 preceding siblings ...)
  2005-11-11 20:49   ` Alexander Skwar
@ 2005-11-11 20:51   ` Billy Holmes
  2005-11-12  1:22   ` Stroller
  4 siblings, 0 replies; 16+ messages in thread
From: Billy Holmes @ 2005-11-11 20:51 UTC (permalink / raw
  To: gentoo-user

Peper wrote:
> And one more thing, is there any smarter way to read one line of file then
> head -n x file|tail -n 1 ?

if you know the line number from the top:

sed -n ${line}p

if you don't know the number from the top but from the bottom, then tail 
| tail is your best bet...
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] Re: [OT] Bash scripting
  2005-11-11 14:12 ` [gentoo-user] " Peper
                     ` (3 preceding siblings ...)
  2005-11-11 20:51   ` Billy Holmes
@ 2005-11-12  1:22   ` Stroller
  4 siblings, 0 replies; 16+ messages in thread
From: Stroller @ 2005-11-12  1:22 UTC (permalink / raw
  To: gentoo-user


On Nov 11, 2005, at 2:12 pm, Peper wrote:

> And one more thing, is there any smarter way to read one line of file 
> then
> head -n x file|tail -n 1 ?

Surely so:

	$ echo 'blahpath="/path/to/blahdir"' >> configfile
	$ echo $blahpath
	
	$ source configfile
	$ echo $blahpath
	/path/to/blahdir
	$ blahpath=$blahpath/foo
	$ echo $blahpath
	/path/to/blahdir/foo
	$

Stroller.

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2005-11-12  1:27 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-11 13:56 [gentoo-user] [OT] Bash scripting Peper
2005-11-11 14:12 ` [gentoo-user] " Peper
2005-11-11 14:19   ` Stoian Ivanov
2005-11-11 15:32   ` Etaoin Shrdlu
2005-11-11 15:45     ` Peper
2005-11-11 20:49   ` Alexander Skwar
2005-11-11 20:51   ` Billy Holmes
2005-11-12  1:22   ` Stroller
2005-11-11 14:14 ` [gentoo-user] " David Eduardo Gómez Noguera
2005-11-11 14:30   ` [gentoo-user] " Peper
2005-11-11 16:34     ` davidgn
2005-11-11 16:58       ` Peper
2005-11-11 14:17 ` [gentoo-user] " Stoian Ivanov
2005-11-11 14:18 ` Jonathan Wright
2005-11-11 14:20 ` Allan Spagnol Comar
2005-11-11 14:22 ` Matthias Guede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox