delete all symbolic character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting delete all symbolic character
# 1  
Old 03-05-2011
delete all symbolic character

Hello

is there a way to delete all symbolic characters using the tr command
or delete everything apart from letters

for example
Code:
input="u;'#n][i.,x/"
input=$(echo $input | tr -d __what do i put here__)
echo $input

i would like echo $input to be "unix"

or a way to only accept letters

PLEASE HELPSmilie

Last edited by Scott; 03-06-2011 at 06:43 AM..
# 2  
Old 03-05-2011
Hi,

Here a way using 'perl':
Code:
$ echo "u;'#n][i.,x/" | perl -lape 's/[^[:alpha:]]*//g'
unix

Regards,
Birei
This User Gave Thanks to birei For This Post:
# 3  
Old 03-05-2011
Code:
tr -cd '[:alpha:]'

[:alpha:] specifies all letters. -c complements that, which means everything that is NOT a letter. -d for delete. The alpha class is quoted to protect it from the shell (a posix-like shell will try pathname expansion on the bracketed word).

Read your friendly neighborhood tr man page for more info. Smilie

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 4  
Old 03-05-2011
Thats it
SOLVED

THANK YOU VERY VERY VERY VERY VERY MUCH

Last edited by omaral; 03-05-2011 at 07:59 PM..
# 5  
Old 03-05-2011
Hi,

-l -> Set line-end processing. Remove it, process line and add it again
-a -> Split line into an array (not neccesary in this case, you can omit it)
-p -> Print line to output
-e -> Enter line of script.
s/[^[:alpha:]]*//g -> Substitute all not alphabetic characters with nothing (remove them of input line). '*' char means to find contiguos ones and 'g' to do it several times until end of input.

Regards,
Birei
This User Gave Thanks to birei For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies

2. Shell Programming and Scripting

Sed: delete on each line before a character and after a character

Hi there, A total sed noob here. Is there a way using sed to delete everything before a character AND after another character on each line in a file? The deletion should also delete the indicating characters(here: an opening and a closing parenthesis). The original file would look like... (3 Replies)
Discussion started by: bnbsd
3 Replies

3. Shell Programming and Scripting

Delete and Recreate around 400 Symbolic Links in one Folder

Hello, I recently just switched my phphandler to suPHP on my server in order to increase security a bit. I am working with 2 scripts, one of which is vbulletin forums and the other is custom. The vbulletin forum avatars are all symbolic links to pictures in the other custom script. When I... (2 Replies)
Discussion started by: ambition13
2 Replies

4. Shell Programming and Scripting

sed to delete character 0 only when it's on its own?

Hi all I am trying to get my head around doing the following.... I have an input field that could contain either a number a blank field or a whitespace field. What I want to do is delete a 0 (zero) if it's on its own or leading the number. So:- \t0 delete the zero 0 delete the... (8 Replies)
Discussion started by: Bashingaway
8 Replies

5. Shell Programming and Scripting

Delete character from a word

Friends, I'm looking for a command that delete the first tho caractere in a word. Here is an exp : I want to replace "20091001" by "091001" or "replace" by "place" Thx, (13 Replies)
Discussion started by: newpromo
13 Replies

6. UNIX for Dummies Questions & Answers

Delete between 10th character and 20th character

Hi, I have a .txt and I need to delete the characters betwwen the 10th and 20th... How can I do that... I need to do somethink like these: %s/I don't know how to define a range between 10th and 20th character//g Can you help me... If I want the 10 first characters i do this:... (2 Replies)
Discussion started by: nuno_fbo
2 Replies

7. Shell Programming and Scripting

delete \n character

Hello. I'm next problem.. I'm a tmp file $ cat tmp word1 word2 word3 word4 and I like have word1 word2 word3 word4 I try with: $ cat tmp |sed 's/\n//' word1 word2 word3 (2 Replies)
Discussion started by: ReneVielma
2 Replies

8. Shell Programming and Scripting

Use sed to delete a character

I built a 12 million record file and made a mistake, one field is 1 character too long. The record is 40 bytes and ends always in 999. I am trying to delete the 37 character in each record. Is this possible without doing a cut and paste. (1 Reply)
Discussion started by: bthomas
1 Replies

9. UNIX for Dummies Questions & Answers

How do I delete a symbolic link?

I just created a symbolic link to a directory using ln -s </remote-directory> < name> I just want to get rid of it. What should I do? muck thanks, rkk (3 Replies)
Discussion started by: ranit
3 Replies

10. UNIX for Advanced & Expert Users

How to delete a character

Hi, T think this is a question for Perderabo. If you think you know the answer you must be very good ! :) Most of us know how the make the <backspace> key backspace a character. Now how do I make the <delete> key delete a character. !! So when I press the delete key the character after... (3 Replies)
Discussion started by: davidg
3 Replies
Login or Register to Ask a Question