Resolved: Building a string with a path in it


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Resolved: Building a string with a path in it
# 1  
Old 12-24-2009
Resolved: Building a string with a path in it

I know this is probably simple, but the brain cells that originally stored my shell scripting classes from 10+ years ago have long since been drowned in beer.

I need to create a string (to append to a file) containing a path derived from the current path. Basically, I want to append "/something" to the end of the results of a "pwd" command. How would I go about this?

Thanks
AS

---------- Post updated at 01:03 PM ---------- Previous update was at 12:56 PM ----------

I found the answer. It was:
Code:
echo `pwd`/something

I new it was simple!

Last edited by Spetnik; 12-24-2009 at 01:06 PM.. Reason: resolved
# 2  
Old 12-24-2009
You don't need an external command for that, the shell variable PWD is available in most shells:

Code:
$PWD/something

# 3  
Old 12-24-2009
Quote:
Originally Posted by radoulov
You don't need an external command for that, the shell variable PWD is available in most shells:

Code:
$PWD/something


pwd is a shell builtin, not an external command.

(But you're right; it's better to use $PWD (available in all POSIX shells), as command substitution is slow.)
# 4  
Old 12-24-2009
Quote:
Originally Posted by cfajohnson

pwd is a shell builtin, not an external command.
[...]
Yes, my mistake.

Thanks for pointing it out!

I saw the backticks and I wrote external command, instead of subshell.

Last edited by radoulov; 12-24-2009 at 07:20 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help building a variable string from a keyword - character replacements!

Hello scripting geniusii! I come to kneel before the alter of your wisdom! I am looking to take a keyword and replace characters within that keyword and add them to a string variable. I would like this to only go through however many characters the word has, which may vary in size. ... (10 Replies)
Discussion started by: ghaniba
10 Replies

2. Shell Programming and Scripting

Parameter value is not getting resolved

Hi, I am using below command and its working fine: $ zcat abc.dat.gz | awk -F\| 'NF==102{print NR,$0}' but when I am using above command in script as below then temp_var2 is not getting resolved. zcat "$1" | awk -F "$2" 'NF==$temp_var2{print NR,$0}' Here, $1 and $2 are parameters which... (2 Replies)
Discussion started by: Prashant298
2 Replies

3. Linux

Find a string in a path

Hi All, I am trying to find a particular string in a path, but able to do so. I tried through grep command but its taking so long time which is not appropriate. e.g: Path : /oct/oracle/apps/OMEC/appl/xxaterp/1.0/reports/US/ Suppose in this path we have 10 .rdf file and I want to... (2 Replies)
Discussion started by: Vikash163
2 Replies

4. Solaris

loghost could not be resolved

Hi friends, I have seen some really annoying error messages since I have installed Solaris, and solved a few of them, with your help. Now, another message pops up in the middle of my work, and says "loghost could not be resolved" Please help me with it. Here are the details for my solaris... (1 Reply)
Discussion started by: gabam
1 Replies

5. Shell Programming and Scripting

if PATH contains a certain string problem!

Hi I am using MKS Toolkit c shell. I want to basically check if my PATH variable already contains a certain path directory so I tried this (it didnt work!): if: Expression Syntax if ( echo $path |grep -c c:/PROGRA~1/blah/blah ) then please help me get this little statement to work. ... (3 Replies)
Discussion started by: vas28r13
3 Replies

6. Shell Programming and Scripting

Determining whether given string is path or not

I have an issue while determing whether given string is unix path or not There is a text file which is normally a report in that at some place we have unix path as shown below /opt/smart/dev/eur/sources/sqr and not unix path as shown below Threshold Year/Month/Ref/ActLine/OUC Is there... (3 Replies)
Discussion started by: lalitpct
3 Replies

7. UNIX for Advanced & Expert Users

Rsync building file list/catalog path/location

Where is the file list created by rsync when it says building file list ? (1 Reply)
Discussion started by: glev2005
1 Replies

8. Programming

Building an argc/argv style structure from a string (char*)

Hello All, First post. I've been struggling with the following: Given a char* string, I need to construct an "int argc, char *argv" style structure. What I'm struggling with most is handling escaped-whitespace and quotes. e.g. the string: char *s = "hello world 'my name is simon'... (10 Replies)
Discussion started by: cbarwise
10 Replies

9. Shell Programming and Scripting

How to set PATH using shell script [resolved]

Hi, Can anyone help me on how to set PATH using shell scripting.. Please find the shell script code here.... #!/bin/bash PATH = $PATH:/opt/app/oracle/product/10.2.0/bin export PATH echo $PATH exit When i execute this script i get the following error ./backup.sh: line 2: PATH:... (0 Replies)
Discussion started by: srinivasj
0 Replies

10. Shell Programming and Scripting

How To Replace A String In File With A String Containing Windows File Path

Hi, I have a file with the following contents # Lines that start with a # are comments. # # Calling TOAD like this will perform a comparison from command line : # # "C:\Program Files\Quest Software\Toad for Oracle 9.6\toad.exe" -c... (2 Replies)
Discussion started by: rajan_san
2 Replies
Login or Register to Ask a Question