Sponsored Content
Top Forums Shell Programming and Scripting trimming trailing slashes in variable Post 302275143 by ricksj on Friday 9th of January 2009 11:15:29 AM
Old 01-09-2009
Thanks for the responses.

I was able to get this to work with the desired results:
Code:
start_dir=`echo "${start_dir}" | sed -e "s/\/*$//" `

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strip leading and trailing spaces only in a shell variable with embedded spaces

I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help. echo $SH_VAR | command_line Syntax. The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Discussion started by: jerardfjay
6 Replies

2. Solaris

spaces trimming while assigning to a variable

Hi my lovely friends, Im writing one pgm in which i trying to assign some values like $var='Jun 6' but if i do echo of this $var will trim the spaces expect one space. $echo $var $Jun 6 But if var='Jun 28', then this will works fine $echo $var $Jun 28 this is required to exctract... (2 Replies)
Discussion started by: Lokesha
2 Replies

3. UNIX for Dummies Questions & Answers

dots and slashes

when I execute a command in like "run.sh," I can run it two ways: ./run.sh or . run.sh What is the difference? (1 Reply)
Discussion started by: DarkLord
1 Replies

4. Shell Programming and Scripting

How to delete trailing zeros from a variable

Hi All I want to delete trailing zeros from varible. ex: if variable value is 1234.567000 result as 1234.567 if variable has 1234.0000 result as 1234 if variable as abcd.fgh result as abcd.fgh Can somone give me a solution using awk? (16 Replies)
Discussion started by: Chandu2u
16 Replies

5. Shell Programming and Scripting

sed - how to remove trailing slashes

I know you can remove trialing slashes using: #echo "/tmp/one/two/three////" | sed "s,/$,," /tmp/one/two/three/// But I want to know how to make it remove all trialing flashes in the front, and in the start, so the end result is: tmp/one/two/three Anyone have any idea how to do this... (6 Replies)
Discussion started by: EXT3FSCK
6 Replies

6. Shell Programming and Scripting

How to remove trailing spaces from a variable?

I am getting a value from a csv file using CUT command, however the command extracting the records with trailing spaces. I am using the result into a sql session to fetch data, because of the trailing spaces the sql session is unable to fetch any data. Please let me know, how to remove this... (2 Replies)
Discussion started by: mady135
2 Replies

7. Shell Programming and Scripting

Trimming spaces from a variable

Hi guys, when I take substring of a particular data using this command var=substr($0,11,10) it comes with spaces, when I am trying to trim the spaces it is not allowing me to do that. Can you please help me out on that. As I have to reverse the output of the variable also. ---------- Post... (0 Replies)
Discussion started by: manish8484
0 Replies

8. UNIX for Dummies Questions & Answers

Want to add trailing spaces to the variable

I want to keep string/varible length to 10 even its actual length is less than 10(may be no value). so, i want to add trailing spaces to my string. :wall: "typeset -L10 myvarible" is not working, its saying invalid typset -L option. Can you please advise. (4 Replies)
Discussion started by: djaks111
4 Replies

9. Shell Programming and Scripting

Preserve trailing whitespace in variable

Hello, I wondering how I can echo a string without having the trailing whitespace removed. For example I have a string str="TESTING123 " that I need to hash using sha1. I get the correct answer when I run the line below from the terminal $ echo -n "TESTING123 " | openssl sha1... (3 Replies)
Discussion started by: colinireland
3 Replies

10. Shell Programming and Scripting

How to remove leading and trailing spaces for variable in shell script?

Hi I have variable named tablename. The value to tablename variable has leading and trailing white spaces. How to remove the leading and training white spaces and write the value of the tablename without space to a file using shell script. ( for e.g. tablename= yyy ) INPUT ... (10 Replies)
Discussion started by: pottic
10 Replies
FileSelect(3)						User Contributed Perl Documentation					     FileSelect(3)

NAME
Tk::FileSelect - a widget for choosing files SYNOPSIS
use Tk::FileSelect; $FSref = $top->FileSelect(-directory => $start_dir); $top - a window reference, e.g. MainWindow->new $start_dir - the starting point for the FileSelect $file = $FSref->Show; Executes the fileselector until either a filename is accepted or the user hits Cancel. Returns the filename or the empty string, respectively, and unmaps the FileSelect. $FSref->configure(option => value[, ...]) Please see the Populate subroutine as the configuration list changes rapidly. DESCRIPTION
This Module pops up a Fileselector box, with a directory entry on top, a list of directories in the current directory, a list of files in the current directory, an entry for entering/modifying a file name, an accept button and a cancel button. You can enter a starting directory in the directory entry. After hitting Return, the listboxes get updated. Double clicking on any directory shows you the respective contents. Single clicking on a file brings it into the file entry for further consideration, double clocking on a file pops down the file selector and calls the optional command with the complete path for the selected file. Hitting return in the file selector box or pressing the accept button will also work. *NOTE* the file selector box will only then get destroyed if the file name is not zero length. If you want yourself take care of it, change the if(length(.. in sub accept_file. AUTHORS
Based on original FileSelect by Klaus Lichtenwalder, Lichtenwalder@ACM.org, Datapat GmbH, Munich, April 22, 1995 adapted by Frederick L. Wagner, derf@ti.com, Texas Instruments Incorporated, Dallas, 21Jun95 HISTORY
950621 -- The following changes were made: o Rewrote Tk stuff to take advantage of new Compound widget module, so FileSelect is now composed of 2 LabEntry and 2 ScrlListbox2 subwidgets. o Moved entry labels (from to the left of) to above the entry fields. o Caller is now able to control these aspects of widget, in both FileSelect (new) and configure : (Please see subroutine Populate for details, as these options change rapidly!) o I changed from Double-Button-1 to Button-1 in the Files listbox, to work with multiple mode in addition to browse mode. I also made some name changes (LastPath --> saved_path, ...). o The show method is not yet updated. o The topLevel stuff is not done yet. I took it out while I toy with the idea of FileSelect as a subwidget. Then the 'normal' topLevel thing with Buttons along the bottom could be build on top of it. o By request of Henry Katz <katz@fs09.webo.dg.com>, I added the functionality of using the Directory entry as a filter. So, if you want to only see the *.c files, you add a .c (the *'s already there :) and hit return. 95/10/17, SOL, LUCC. lusol@Lehigh.EDU o Allow either file or directory names to be accepted. o Require double click to move into a new directory rather than a single click. This allows a single click to select a directory name so it can be accepted. o Add -verify list option so that standard Perl file test operators (like -d and -x) can be specified for further name validation. The default value is the special value '!-d' (not a directory), so any name can be selected as long as it's not a directory - after all, this IS FileSelect! For example: $fs->configure(-verify => ['-d', [&verify_code, $P1, $P2, ... $Pn]]); ensures that the selected name is a directory. Further, if an element of the list is an array reference, the first element is a code reference to a subroutine and the remaining optional elements are it's parameters. The subroutine is called like this: &verify_code($cd, $leaf, $P1, $P2, ... $Pn); where $cd is the current directory, $leaf is a directory or file name, and $P1 .. $Pn are your optional parameters. The subroutine should return TRUE if success or FALSE if failure. 961008 -- derf@ti.com : By request of Jim Stern <js@world.northgrum.com> and Brad Vance <bvance@ti.com>, I updated the Accept and Show functions to support selection of multiple files. I also corrected a typo in the -verify code. SEE ALSO
Tk::getOpenFile, Tk::FBox. perl v5.16.3 2014-06-10 FileSelect(3)
All times are GMT -4. The time now is 04:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy