The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Unable to use sort command in Shell Script racbern Shell Programming and Scripting 1 04-04-2008 06:25 AM
Unable to use 'su' command on FreeBSD6.2 Praveen_218 BSD 3 02-28-2008 02:45 AM
unable to sent mail in html format by mailx command. p_prathaban UNIX for Advanced & Expert Users 17 11-07-2007 03:03 AM
unable to display the souce line in gdb gauri UNIX for Dummies Questions & Answers 4 04-19-2007 09:36 PM
UNable to find ping command swepaul UNIX for Dummies Questions & Answers 3 05-30-2005 03:17 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-07-2008
bosh bosh is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 3
unable to use command line to cd or ls

Hi:

I have a script with the next command line

>set a=(grep -w "something" textfile.txt | grep -w "anotherthing" | cut -c1-11)

In the file textfile.txt there are some file names and their paths so when I use this command line it returns a path, for example /directory, and stores in a.

when I try
>cd $a
it comes with the error "Too many arguments", I know that $a is /directory, but if i do >echo $a it returns the command line, this is why i cant use cd $a.

is there a way to actually store the file path into the variable and not the command line. So when ever do >set | grep a it will acutally display
a /directory

I really need you help.

Thank you
  #2 (permalink)  
Old 03-08-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,124
Use:
echo "$a"
to debug the problem.
  #3 (permalink)  
Old 03-08-2008
bosh bosh is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 3
Sorry i probably dont explained my self, what i am trying to do is
>cd $a
or
>ls $a

but none of this work and i have tried >cd echo $a, and >$a | cd
both for cd and ls... i know that when i execute just $a i get the path that was copied from the textfile.txt, but when i see what the variable contain it contains the command line, eval grep -w "something" textfile.txt | grep -w "anotherthing" | cut -c1-11.

please tell me how to use either cd or ls with the value i get from the execution of the command line (grep -w "something" textfile.txt | grep -w "anotherthing" | cut -c1-11)

Thank you
  #4 (permalink)  
Old 03-08-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,124
I think you're probably using csh with that syntax and I don't really know csh real well. Also I'm not sure what you're trying to do. But to get the results of a command line into a variable, try using backquotes. I just tried this with csh...
Code:
%echo 1+2 | bc
3
%set a=`echo 1+2 | bc`
%echo $a
3
%
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0