![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to print selected pages | wendyz | UNIX for Dummies Questions & Answers | 2 | 10-14-2008 12:53 PM |
| Print out a selected word. | anakiar | Shell Programming and Scripting | 10 | 07-28-2008 04:29 AM |
| last char from a string | broli | Shell Programming and Scripting | 6 | 12-07-2007 08:02 PM |
| print selected lines | tonet | Shell Programming and Scripting | 6 | 10-08-2007 05:50 AM |
| print selected rows with awk | tonet | Shell Programming and Scripting | 6 | 09-27-2007 06:23 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Need to print only selected char in a string..?
Hi,
I want to print particular chars in a string. for example ie., consider " dear,. roopa$#09%~`';'][\.@ " as the example string. Here, I want to print only alphanumeric chars.. suppose , if i want only alphanumeric... value would be "dear roopa09" suppose , if i want some spl char(,) with alphanumeric...ans would be "dear, roopa09" It could be anything, like only numeric chars or alphabetic or only . symbol or * symbol... anything. plz, give ur valuable solution. Thanx, Balan ![]() |
|
||||
|
below script has only three options,
1> only print the digit number 2> only print the alpha 3> only print the special characters You may amend it to fully address your desire. Hope make sense to you! a.txt: Code:
dear,. roopa$#09%~`';'][\.@ Code:
echo "Enter your type: 1[digit],2[alpha],3[special],4[exit]" read type if [ $type -eq 1 ] then cat a.txt | sed 's/[^0-9]//g' fi if [ $type -eq 2 ] then cat a.txt | sed 's/[^a-zA-Z]//g' fi if [ $type -eq 3 ] then cat a.txt | sed -e 's/[0-9]//g' -e 's/[a-zA-Z]//g' fi if [ $type -eq 4 ] then exit fi |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|