Sponsored Content
Top Forums Shell Programming and Scripting Removing substring from a string Post 79584 by dmilks on Thursday 28th of July 2005 03:01:50 PM
Old 07-28-2005
Removing substring from a string

Hi. I want to remove a substring from a string. If I use the "tr" command, it doesn't seem to to what I want it to:

echo './somestring.dat' | tr -d './'
results in
somestringdat

I want it to remove only occurances of the string './', rather than the individual character. The result should be: somestring.dat

How do I do this?

Thanks,
- Dylan
 

10 More Discussions You Might Find Interesting

1. Programming

can i get a substring from a string?

for example, the string a is "abcdefg", can i get a substring "bcd" (from ato a) from string a? thank you (4 Replies)
Discussion started by: dell9
4 Replies

2. Shell Programming and Scripting

getting a substring from a string

hi all, I am trying to extract SUBSTRINGS out of a string using ksh. The string is "SAPR3K.FD0.FA.TJ.B0010.T050302" I tried using a= `expr substr $stringZ 1 2` which is giving me a syntax error, donno why?? any ideas why its not working?? I also tried echo "welcome" | awk '{... (3 Replies)
Discussion started by: maradona
3 Replies

3. UNIX for Dummies Questions & Answers

How to get the substring from the string

Hi All, Can anybody help me to get the substring from the given string. (3 Replies)
Discussion started by: Anshu
3 Replies

4. Shell Programming and Scripting

get substring from string

Hi All, Problem Description: XML_REP_REQUEST=`CONCSUB "$LOGIN" "SQLAP" "$RESP_NAME" "$USRNM" WAIT="Y" "CONCURRENT" "APPLICATION_SHORT_NAME" "CP_SHORT_NAME"` echo Report Request: $XML_REP_REQUEST --to print value in log file While execution the value of 'XML_REP_REQUEST' is 'Prozess... (5 Replies)
Discussion started by: suman.g
5 Replies

5. Shell Programming and Scripting

Help with string and substring also I/O

#!/bin/sh PRINTF=/usr/bin/printf PASSWD=/etc/passwd $PRINTF "Enter a UserID\n" read USERID if ; then $PRINTF "$USERID does not exist, please contact IT service\n" exit 1 fi USERHOME=`grep "^$USERID:" $PASSWD | awk -F : '{print $6}'` USERSHELL=`grep "^$USERID:"... (1 Reply)
Discussion started by: ikeQ
1 Replies

6. Shell Programming and Scripting

Substring in string with whitespaces

hello, i have this string: variable="1234 /PARAMETER_1:text /PARAMETER_2:othertext" i tried to do expr match $variable '.*\(*\)' but i keep getting expr error i need to extract the word text... thank you (4 Replies)
Discussion started by: Aloush89
4 Replies

7. Shell Programming and Scripting

Replacing a string with its substring

Hi All, Below is some sample content of my input file: There are many types and traditions of anarchism, some of which are ]. Strains of anarchism have been divided into the categories of ] and ] or similar dual classifications. Anarchism is often considered to be a radical ] ideology, and... (8 Replies)
Discussion started by: satheeshkumar
8 Replies

8. Shell Programming and Scripting

Remove a substring from string

Good morning friends, how can i remove a string with linux scripting from a file? In specific i want to remove from a file all the tweet names and links eg @aerta and links such as http://dst.co/pIiu3i9c Thanx!!! (4 Replies)
Discussion started by: paladinaeon
4 Replies

9. UNIX for Beginners Questions & Answers

Renaming batch by removing substring

I wish to rename all files ending in .txt by removing .tex. Currently I have me@me-Inspiron-518:~$ ls a.tex.txt bin b.tex.txt c.tex.txt Desktop Documents Downloads d.tex.txt Music Pictures Public Templates VideosDesired outcome me@me-Inspiron-518:~$ ls a.txt ... (2 Replies)
Discussion started by: Xubuntu56
2 Replies

10. Shell Programming and Scripting

Extracting substring within string between 2 token within the string

Hello. First best wishes for everybody. here is the input file ("$INPUT1") contents : BASH_FUNC_message_begin_script%%=() { local -a L_ARRAY; BASH_FUNC_message_debug%%=() { local -a L_ARRAY; BASH_FUNC_message_end_script%%=() { local -a L_ARRAY; BASH_FUNC_message_error%%=() { local... (3 Replies)
Discussion started by: jcdole
3 Replies
MEMMEM(3)						   BSD Library Functions Manual 						 MEMMEM(3)

NAME
memmem -- locate substring in byte string LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <string.h> void * memmem(const void *block, size_t blen, const void *pat, size_t plen); DESCRIPTION
The memmem() function locates the first occurrence of the binary string pat of size plen bytes in the byte string block of size blen bytes. RETURN VALUES
The memmem() function returns a pointer to the substring located, or NULL if no such substring exists within block. If plen is zero, block is returned, i.e. a zero length pat is deemed to match the start of the string, as with strstr(3). SEE ALSO
bm(3), memchr(3), strchr(3), strstr(3) STANDARDS
The memmem() function is not currently standardized. However, it is meant to be API compatible with functions in FreeBSD and Linux. HISTORY
memmem() first appeared in the Free Software Foundation's glibc library. BSD
March 12, 2005 BSD
All times are GMT -4. The time now is 03:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy