Sponsored Content
Top Forums Shell Programming and Scripting sed - how to remove trailing slashes Post 302357363 by 64mb on Tuesday 29th of September 2009 12:57:00 PM
Old 09-29-2009
I should have realised that Smilie

Thank you vgersh99 and Franklin52 Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed command for using with back slashes

hi all, im trying to use a sed command to remove all occurenes of \p\g what i used so far is : sed 's!\p\g!!g' file but this doesnt work ? Any ideas, thanks for helping. (2 Replies)
Discussion started by: seaten
2 Replies

2. UNIX for Dummies Questions & Answers

How to remove trailing spaces

Hi, I have a file like this (ADD_MONTHS((Substr(Trim(BOTH FROM Translate(Maximum(closeDa ------------------------------------------------------------ 2007-06-30 00:00:00 I have a requirement where i need just the date. When i do: tail -1... (2 Replies)
Discussion started by: mahek_bedi
2 Replies

3. Shell Programming and Scripting

Remove trailing G

Hello, I am trying to write a script that will calculate the amount of data remaining in a storage volume. I'm running Tru64 Unix version 5.1B patch kit 6. The script is being run against an AdvFS domain. I am programming in Korn Shell version M-11/16/88f. The basic idea is that I want to run df... (3 Replies)
Discussion started by: Heathe_Kyle
3 Replies

4. Shell Programming and Scripting

trimming trailing slashes in variable

I'm using this thread as an example, but can't seem to apply it to my situation. I'm trying to strip the trailing slash (/) from an input argument. Here's a snippet of my command line input and the troublesome code: $ script_name -s "../pathname/dir/" snip 8< ... while getopts :s:... (5 Replies)
Discussion started by: ricksj
5 Replies

5. UNIX for Dummies Questions & Answers

Remove Colons and Slashes from 2nd Token

I would prefer to use Sed, but I will do whatever necessary. I want to know a good way to remove ":" and "/" from the first string surrounded in Double quotes, but not the 2nd. Current File: "9781238274584-Ace of Spades: The Poop" "Ace of Spades: The Poop" ...Desired: "9781238274584-Ace of... (6 Replies)
Discussion started by: glev2005
6 Replies

6. Shell Programming and Scripting

How to use sed when a match has forward slashes

I'm trying to replace an alias with its match using sed but the match contains forward slashs so it causes the sed command to throw a garbled message.. cmd_list.txt sample AIX_myserver_1011_vintella.sudoers_cmndalias sample I'm trying to use the below but like I say it throws a... (5 Replies)
Discussion started by: Jazmania
5 Replies

7. Shell Programming and Scripting

Using SED to copy/paste with slashes and tabs.

I have: 2012/01_January/Kite/foldername/otherfoldername/placeholderBlue I want to end up with: /foldername/otherfoldername/2012/01_January/Kite/Blue Basically take everything before the first tab and put it in the place of the consistently named word placeholder and add a slash in place... (2 Replies)
Discussion started by: crowman
2 Replies

8. Shell Programming and Scripting

Remove trailing zeros

Hi I have a simple request but can't find the answer. I want to remove trailing zeros, and in some cases the fullstops, from the input data. Example of input file: FR002_15.000_20.000 SD475_5.000_10.500 FG5647_12.250_15.500 BH2463_30.555_32.000 Desired output file would be: ... (10 Replies)
Discussion started by: theflamingmoe
10 Replies

9. Shell Programming and Scripting

Remove trailing 0 from the field

Hi Freinds, I have file1.txt as below file1.txt 1521894~~-0.400~201207 1521794~~-0.486~201207 152494~~-0.490~201207 152154894~~-0.490~201207 1521894354~~-0.489~201207 expected output : 1521894~~-0.4~201207 1521794~~-0.486~201207 152494~~-0.49~201207... (9 Replies)
Discussion started by: i150371485
9 Replies

10. Shell Programming and Scripting

Remove trailing number

I have some strings such as ABC1 ABC2 TYFASDD12 They will only have letters and numbers. In each case I want to remove the last digit? The lengths will vary. So a hard coded substr won't work. What do I do? if it doesn't end in a number, I don't want to remove any characters. (6 Replies)
Discussion started by: guessingo
6 Replies
BASENAME(1)						    BSD General Commands Manual 					       BASENAME(1)

NAME
basename, dirname -- return filename or directory portion of pathname SYNOPSIS
basename string [suffix] basename [-a] [-s suffix] string [...] dirname string [...] DESCRIPTION
The basename utility deletes any prefix ending with the last slash '/' character present in string (after first stripping trailing slashes), and a suffix, if given. The suffix is not stripped if it is identical to the remaining characters in string. The resulting filename is written to the standard output. A non-existent suffix is ignored. If -a is specified, then every argument is treated as a string as if basename were invoked with just one argument. If -s is specified, then the suffix is taken as its argument, and all other arguments are treated as a string. The dirname utility deletes the filename portion, beginning with the last slash '/' character to the end of string (after first stripping trailing slashes), and writes the result to the standard output. EXIT STATUS
The basename and dirname utilities exit 0 on success, and >0 if an error occurs. EXAMPLES
The following line sets the shell variable FOO to /usr/bin. FOO=`dirname /usr/bin/trail` SEE ALSO
csh(1), sh(1), basename(3), dirname(3) STANDARDS
The basename and dirname utilities are expected to be IEEE Std 1003.2 (``POSIX.2'') compatible. BSD
April 18, 1994 BSD
All times are GMT -4. The time now is 09:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy