How to filter Alphanumerics


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to filter Alphanumerics
# 1  
Old 08-10-2010
How to filter Alphanumerics

Hi all,

Can you please let me know how to achieve the below thing

AAABBCC@#$W123
123@#$DFG<>.

Output:
AAABBCW123
123DFG

i.e I want to filer only alphanumerics from the strings
# 2  
Old 08-10-2010
Code:
sed -e 's/[^A-Za-z0-9]//g' file

This User Gave Thanks to fpmurphy For This Post:
# 3  
Old 08-11-2010
thanks !
# 4  
Old 08-11-2010
Code:
sed -e 's/[:alnum:]//g'

should also work I guess..
# 5  
Old 08-11-2010
Code:
tr -cd '[:alnum:]\n'



---------- Post updated at 12:41 AM ---------- Previous update was at 12:39 AM ----------

Quote:
Originally Posted by rajamadhavan
Code:
sed -e 's/[:alnum:]//g'

should also work I guess..
It won't. What you're going for is:
Code:
sed -e 's/[^[:alnum:]]//g'

Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Filter records in a huge text file from a filter text file

Hi Folks, I have a text file with lots of rows with duplicates in the first column, i want to filter out records based on filter columns in a different filter text file. bash scripting is what i need. Data.txt Name OrderID Quantity Sam 123 300 Jay 342 498 Kev 78 2500 Sam 420 50 Vic 10... (3 Replies)
Discussion started by: tech_frk
3 Replies

2. Shell Programming and Scripting

How the filter output?

Hey, I'm using some sensors that can be read by http. If I run following command: curl -v 'http://192.168.111.23:8080/sensor/52f5c63cc4221fbbedcb499908a0a823?version=1.0&interval=minute&unit=watt&callback=realtime' I'm getting: I would like to put this now in a sheet with only the... (9 Replies)
Discussion started by: brononius
9 Replies

3. UNIX for Dummies Questions & Answers

Help me to filter a file

I want to view a file ignoring mutilple comment line (/*....*/). Please help me on this. Advance thanks.:b: (5 Replies)
Discussion started by: Pradipta Kumar
5 Replies

4. Shell Programming and Scripting

grep and alphanumerics

Hi Experts, I'm facing an issue with grep or may be Im missing something. Following are the details Input file # more regexp asdh1987 dog897you 981towm 1234oqn 4yuop8pou sam99917c00l Akoold0g8 data sample data Im trying to grep out only the alphanumeric entries and following... (10 Replies)
Discussion started by: maverick_here
10 Replies

5. Shell Programming and Scripting

How to filter

Hi I have a file containing the below lines 1010001001639 1010001001789 1020001001927 1030001001928 1040001002033 1200001002609 1200001003481 1200001004935 I need to filter lines that starts with 101. It would be of great help if its in awk. (6 Replies)
Discussion started by: Naga06
6 Replies

6. Shell Programming and Scripting

Gawk filter

People, Ive been trying to make a script but i just cant figure it out. Problem/ Case: I have a logfile.txt that contains data. The only two things i need to filter on = $1 (date), $6 (errorcode). In the script i am trying to make, u need to fill in a date. So he searches on that date... (11 Replies)
Discussion started by: Pow3R
11 Replies

7. Shell Programming and Scripting

Filter on a grep

I am attempting to figure out how to only capture part of a grep command I am doing. So far no luck. When I execute.... leviathan:/gfs/home/tivoli>ps -ef | /usr/ucb/ps -auxww | grep nco_p_syslog The results are.... tivoli 10185 0.0 0.0 5888 5168 ? S Oct 23 0:26... (2 Replies)
Discussion started by: LRoberts
2 Replies

8. UNIX for Dummies Questions & Answers

Filter using awk

Hi, I need to filter the output of a command and display omitting the first 6 lines and the last two lines..How can i do this using awk. command | awk ' NR > 7' will omitt the first 6 lines but dont know how to omit the last two lines.. can anyone help? (3 Replies)
Discussion started by: arun_st
3 Replies

9. Shell Programming and Scripting

Strip all non-alphanumerics

Hi, Can someone let me know how do I strip out any non-alphanumeric character in string tomake it alphanumeric? i.e abc def ghi ->abcdefghi abc-def-ghi ->abcdefghi abc#def-ghi->abcdefghi Thanks in advance (3 Replies)
Discussion started by: braindrain
3 Replies

10. UNIX for Dummies Questions & Answers

Use non alphanumerics in join

Hi, I have a problem while joining two sorted files with "join". File 1.txt Alnus|123 ALO140102|234 ALO 1401 02|345 ALO-1401-02|456 Alobar Holoprosencephalies|567 File 2.txt 1|Alnus| 1|ALO 1401 02| 1|ALO-1401-02| 1|Alobar Holoprosencephalies| If I join the files as follows:... (1 Reply)
Discussion started by: s0460205
1 Replies
Login or Register to Ask a Question