Computing.Net > Forums > Linux > assigning variables

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

assigning variables

Reply to Message Icon

Name: mgonzalo
Date: February 4, 2009 at 08:06:37 Pacific
OS: Suse Linux 10
CPU/Ram: 2 x INTEL XEON X5460 quadcore 3.16 GHz
Product: Hewlett-packard / Hp proliant dl380 g5
Subcategory: General
Comment:

How do I save the directory where I'm working on a variable?
p.e.
linux:/home/valida/pruebas/aaaa >pwd
/home/valida/pruebas/aaaa

I make the following
pwd > work
set work_dir = 'cut -c1-40 work`
echo $work_dir

and I output
/home/valida/pruebas/aaaa

How can I make it easier?

"La experiencia es algo maravilloso. Nos permite reconocer un error cada vez que lo volvemos a cometer.", Franklin P. Jones



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: February 4, 2009 at 08:36:23 Pacific
Reply:

First, based on your syntax, I'm assuming you are using the "C" shell. Also, I don't understand what you are cutting, but you probably have a reason.

Second, I see no reason to redirect the pwd output to a file. Use command substituition and a pipe:

#!/usr/bin/csh

set work = `pwd`
set workdir = `echo "$work"|cut -c1-40`
echo $workdir

#or even more simple:

set workdir = `pwd|cut -c1-40`
echo $workdir


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: assigning variables

csh script && positional parameters www.computing.net/answers/linux/csh-script-ampamp-positional-parameters/1490.html

How to md5sum a variable content www.computing.net/answers/linux/how-to-md5sum-a-variable-content/14153.html

Linux Scripting variables www.computing.net/answers/linux/linux-scripting-variables/19210.html