Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Extract directory path from a parameter Post 303042849 by RudiC on Wednesday 8th of January 2020 11:27:55 AM
Old 01-08-2020
The wild card will be expanded in your script. It should work if exactly one single pattern matched; it fails if none or more than one matched.


Try a for loop in your script.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to find the path of a file when it is passed as ....filename(parameter) to script

hi unix guru's..................:confused: question is posted in the #3 permalink shown below. (3 Replies)
Discussion started by: yahoo!
3 Replies

2. Shell Programming and Scripting

Extract directory from a file path

Im trying to extract a directory from a path entered by the user Lets say the path is path=/home/bliss/files/myfile.txt i wanna extract "/home/bliss/files" from $path ... how can i do this? (4 Replies)
Discussion started by: mrudula009
4 Replies

3. Shell Programming and Scripting

Extract path within path

Hi, I have a environmental variables, ORACLE_HOME=/u01/oracle/ORCL/db/tech/10.2.0 ORACLE_SID=ORCL Now I need to create a variable and need to extract some part from ORACLE_HOME. I need to get the path from ORACLE_HOME till ORACLE_SID as /u01/oracle/ORCL. I may need to check also... (6 Replies)
Discussion started by: sreejitnair123
6 Replies

4. Shell Programming and Scripting

one liner to extract path from PATH variable

Hi, Could anyone help me in writing a single line code by either using (sed, awk, perl or whatever) to extract a specific path from the PATH environment variable? for eg: suppose the PATH is being set as follows PATH=/usr/bin/:/usr/local/bin:/bin:/usr/sbin:/usr/bin/java:/usr/bin/perl3.4 ... (2 Replies)
Discussion started by: royalibrahim
2 Replies

5. Shell Programming and Scripting

How to extract and replace with parameter value?

Hi, I have a function getparam() which takes parameter name as input and parameter value as output. I have a strting like this, abcd#paramname1#efgh#paramname2#ijklmnopq Above one is my input, The strting enclosed in # are the parameter names. Here question is, I have to get the... (0 Replies)
Discussion started by: anandapani
0 Replies

6. Shell Programming and Scripting

Retrieve directory path from full file path through sh

Hi, I have a file abcd.txt which has contents in the form of full path file names i.e. $home> vi abcd.txt /a/b/c/r1.txt /q/w/e/r2.txt /z/x/c/r3.txt Now I want to retrieve only the directory path name for each row i.e /a/b/c/ /q/w/e/ How to get the same through shell script?... (7 Replies)
Discussion started by: royzlife
7 Replies

7. Shell Programming and Scripting

How to extract strings from full path when full path is not fixed

/Path/snowbird9/nrfCompMgrRave1230100920.log.gz:09/20/2010 06:14:51 ERROR Error Message. /Path/snowbird6/nrfCompMgrRave1220100920.log.gz:09/20/2010 06:14:51 ERROR Error Message. /Path/snowbird14/nrfCompMgrRave920100920.log.gz:09/20/2010 06:14:51 ERROR Error Message.... (0 Replies)
Discussion started by: Shirisha
0 Replies

8. UNIX for Dummies Questions & Answers

Extract directory name from the full directory path in UNIX using shell scripting

My input is as below : /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/loyal/IFIND.HELLO.WROC.txt /splunk/scrubbed/triumph/ifind.triumph.txt From the above input I want to extract the file names only . Basically I want to... (5 Replies)
Discussion started by: IshuGupta
5 Replies

9. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies

10. UNIX for Beginners Questions & Answers

What is the difference ../directory path and ./directory path in ksh?

What is the difference ../directory path and ./directory path in ksh? (1 Reply)
Discussion started by: TestKing
1 Replies
try(3tcllib)                                       Forward compatibility implementation of [try]                                      try(3tcllib)

__________________________________________________________________________________________________________________________________________________

NAME
try - try - Trap and process errors and exceptions SYNOPSIS
package require Tcl 8.5 package require try ?1? ::try body ?handler...? ?finally script? _________________________________________________________________ DESCRIPTION
This package provides a forward-compatibility implementation of Tcl 8.6's try/finally command (TIP 329), for Tcl 8.5. The code was directly pulled from Tcl 8.6 revision ?, when try/finally was implemented as Tcl procedure instead of in C. ::try body ?handler...? ?finally script? This command executes the script body and, depending on what the outcome of that script is (normal exit, error, or some other excep- tional result), runs a handler script to deal with the case. Once that has all happened, if the finally clause is present, the script it includes will be run and the result of the handler (or the body if no handler matched) is allowed to continue to propa- gate. Note that the finally clause is processed even if an error occurs and irrespective of which, if any, handler is used. The handler clauses are each expressed as several words, and must have one of the following forms: on code variableList script This clause matches if the evaluation of body completed with the exception code code. The code may be expressed as an integer or one of the following literal words: ok, error, return, break, or continue. Those literals correspond to the integers 0 through 4 respectively. trap pattern variableList script This clause matches if the evaluation of body resulted in an error and the prefix of the -errorcode from the interpreter's status dictionary is equal to the pattern. The number of prefix words taken from the -errorcode is equal to the list-length of pattern, and inter-word spaces are normalized in both the -errorcode and pattern before comparison. The variableList word in each handler is always interpreted as a list of variable names. If the first word of the list is present and non-empty, it names a variable into which the result of the evaluation of body (from the main try) will be placed; this will contain the human-readable form of any errors. If the second word of the list is present and non-empty, it names a variable into which the options dictionary of the interpreter at the moment of completion of execution of body will be placed. The script word of each handler is also always interpreted the same: as a Tcl script to evaluate if the clause is matched. If script is a literal - and the handler is not the last one, the script of the following handler is invoked instead (just like with the switch command). Note that handler clauses are matched against in order, and that the first matching one is always selected. At most one han- dler clause will selected. As a consequence, an on error will mask any subsequent trap in the try. Also note that on error is equivalent to trap {}. If an exception (i.e. any non-ok result) occurs during the evaluation of either the handler or the finally clause, the origi- nal exception's status dictionary will be added to the new exception's status dictionary under the -during key. EXAMPLES
Ensure that a file is closed no matter what: set f [open /some/file/name a] try { puts $f "some message" # ... } finally { close $f } Handle different reasons for a file to not be openable for reading: try { set f [open /some/file/name] } trap {POSIX EISDIR} {} { puts "failed to open /some/file/name: it's a directory" } trap {POSIX ENOENT} {} { puts "failed to open /some/file/name: it doesn't exist" } BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category try of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
catch(3tcl), error(3tcl), return(3tcl), throw(3tcl) KEYWORDS
cleanup, error, exception, final, resource management CATEGORY
Utility COPYRIGHT
Copyright (c) 2008 Donal K. Fellows, BSD licensed try 1 try(3tcllib)
All times are GMT -4. The time now is 08:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy