Sponsored Content
Top Forums Shell Programming and Scripting passing file extension using external variable Post 302706245 by nrjrasaxena on Wednesday 26th of September 2012 10:59:27 AM
Old 09-26-2012
passing file extension using external variable

Hi,
How can I modify the FILETYPE command ?
I want to provide the file extension, like txt, root .?

Thanks,
Code:
#!/bin/bash                                                                                                                                           

FROM=$1
TO=$2
FILETYPE=$3

for i in *$FILETYPE; do
    mv ${i} ${i/$FROM/$TO}
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing value to an external program problem...

This code is in my 'case' statement and it all else works fine. The problem I have is that the value in 'procno' is not passed on to the external program (fireit). It is passing all zeros instead of the actual process number. By the time I get to this case statement, I know the "Number" and... (1 Reply)
Discussion started by: giannicello
1 Replies

2. Shell Programming and Scripting

Getting category when given the variable from external file to shell script

Hi, I have a script that interacts with a config file in the format: file1.txt file2.txt file3.txt file4.txt file5.txt file6.txt I would like to return the Category, when given the file name. (11 Replies)
Discussion started by: MoreCowbell
11 Replies

3. Shell Programming and Scripting

Passing answers to external program from KSH

I have asked this before but I haven't had any luck so far getting this to work. I use RCS(revision control system). When it runs if I pass the value 'unlock' to $3 its reassigned to $unlock. When I run the command (rcs -u'version number' 'filename') ti will ask me 1-(Do you want to break the lock... (5 Replies)
Discussion started by: pjones006
5 Replies

4. Shell Programming and Scripting

passing arguments to external script

Hi! I have a python script that requires arguments and these arguments are file paths. This script works fine when executed like this: /my_python_script "file_path1" "file_path2" (i added quotes as some file names may have weird characters) the issue happens when i launch my python script... (14 Replies)
Discussion started by: gigagigosu
14 Replies

5. Shell Programming and Scripting

[Solved] Value of a variable is not recognised for commands comes from external file

Hi, my script is setting a variable with value and this variable is present in my another command that is coming from external file and this command is internally called after this variable is set. but while execution of this command, the value is not retrieved properly. say, my script... (5 Replies)
Discussion started by: rbalaj16
5 Replies

6. Shell Programming and Scripting

How can we assign value to an array variable from an external file?

is it possible to assign value to an array variable from an external file?? if yes then how?? I am using below code but its not working. #!bin/bash myarray < file_name echo ${mayarray} (6 Replies)
Discussion started by: mukulverma2408
6 Replies

7. Shell Programming and Scripting

Passing external variable to awk

Hi, I am trying to write a bash script in which I need to pass a external variable to the awk program. I tired using -v but it not accepting the value. Here is my sample code. #!/usr/bin/bash ###################################################################################### ####... (5 Replies)
Discussion started by: jpkumar10
5 Replies

8. Shell Programming and Scripting

Passing variable from file to Oracle

cat a1 scott robert tom test script : #!/usr/bin/ksh for NAME in `cat a1` do VALUE=`sqlplus -silent "nobody/bobody01@testq" <<END set pagesize 0 feedback off verify off heading off echo off select username from dba_users where username=upper('$NAME'); END` if ; then echo... (3 Replies)
Discussion started by: jhonnyrip
3 Replies

9. UNIX for Beginners Questions & Answers

Passing a file name to a variable

Below is the command mv AP_FLEXCUBE_INTERFACE10.txt FTPYMNTE_`date "+%Y%m%d%H%M%S" | tr '' ''`.TXT it is changing the file name to a different name according to time stamp dynamically. I want to capture that dynamic file name present in the directory to a variable . After that i want to... (6 Replies)
Discussion started by: sujit das
6 Replies

10. Shell Programming and Scripting

Duplicate check by passing external parameter

I have a code which is using to find duplicates in a files based on column.Below is the same code which is used to find duplicates in my file based on column 1 awk -F'|' '{if (x) { x_count++; print $0; if (x_count == 1) { print x } } x = $0}' FileName >Dup_File.txt But my requirement here is... (3 Replies)
Discussion started by: ginrkf
3 Replies
TclXSLT(n)																TclXSLT(n)

__________________________________________________________________________________________________________________________________________________

NAME
::xslt::compile - SYNOPSIS
package require xslt xslt2.5 ::xslt ::xslt::compile doc ssheet method ? option value ... ? ? args ... ? ::xslt::extensionadd nsuri tcl-namespace _________________________________________________________________ DESCRIPTION
TclXSLT is a wrapper for the that allows an application to perform XSL transformations (XSLT). The package also provides a binding to the XSLT extension mechanism so that XSLT extension may be implemented using Tcl scripts. Transformation only works with documents created by TclDOM/libxml2. The TclXSLT package makes extensive use of Tcl objects. Compiled XSL stylesheets are stored as the internal representation of a Tcl object. Source and result documents are accessed via TclDOM's C interface as Tcl objects. This allows the application to cache parsed XML documents and compiled XSL stylesheets for better runtime performance. PACKAGES AND NAMESPACES
The TclXSLT package defines the package and also a Tcl namespace using that name. COMMANDS
::xslt::compile The ::xslt::compile command pre-compiles a stylesheet document. It returns a compiled stylesheet object and also defines a Tcl command to access the stylesheet. This Tcl command may be used to transform XML documents. NB. It is advisable to use the -baseuri option when parsing the source and stylesheet documents to allow external resources to be resolved. Stylesheet Command The stylesheet command created by ::xslt::compile command accesses a compiled stylesheet. Following is an example of how to use the stylesheet transform method. Command Methods The following command methods may be used: cget option Returns the value of an option. See below for the list of valid options. configure optionvalue Sets the value of an option. Available options are as follows: transform source ? name value? Performs an XSL transformation on the given source document. Stylesheet parameters may be specified as name-value pairs. The return result is the DOM token for the result document. Stylesheet Parameters Any number of name-value pairs may be specified as arguments to the stylesheet transform method. These are passed as values for parameters in the stylesheet. interprets the values as XPath expressions, where the context node is the root node for the source document. To pass a value as a string it must be XPath-quoted, for example set library "Gnome libxslt" $ssheet transform $source_doc library '$library' author "'Daniel Veillard'" node {/*/Element[3]} ::xslt::extension The ::xslt::extension command is used to manage extensions of the library. The add is used to register an extension. The remove is used to unregister an extension. See for more detail. EXTENSIONS
The TclXSLT package allows an application to bind Tcl scripts to the extension mechanism of . This means that Tcl scripts may provide the implementation of an XSLT extension element or function. The binding is achieved to associating a Tcl namespace with an XML namespace. Implementing An Extension The Tcl application uses the ::xslt::extension add command to register an extension. An XML Namespace for the extension is specified as an argument, along with a Tcl namespace that will provide implementations of extension elements and functions. For example, Everytime the ::xslt::transform command is executed, a newly-created XSLT engine is initialized. For each registered extension, every pro- cedure in the associated Tcl namespace is defined in the XSLT engine as either an extension element or an extension function. The proce- dure is defined as an extension function if it has a variable argument list, otherwise it is defined as an extension element. The proce- dure name is used as the local part of the extension name. For example, "myfunc" is defined as an extension function and "myelement" is defined as an extension element. Extension Functions The arguments to an extension function are converted to a string value and then passed as parameters to the Tcl procedure. The return result of the Tcl procedure becomes the return value of the extension function. The type of the result is preserved where possible, otherwise it is converted to a string value. Extension Elements Extension elements have not been implemented in TclXSLT v1.1. Using An Extension To invoke an extension in an XSL stylesheet, use the normal XSLT extension mechanism. The XML Namespace matches the extension to the reg- istered Tcl namespace (NB. the stylesheet author is free to choose any prefix for the extension namespace). For example, This stylesheet would result in the following Tcl script being evaluated: Tcl Built-In Commands Tcl TclXSLT(n)
All times are GMT -4. The time now is 06:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy