how to use sed command with alphabetical and spaces?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to use sed command with alphabetical and spaces?
# 1  
Old 09-07-2008
how to use sed command with alphabetical and spaces?

If have a problem with this command:

name="toe der"
echo $name | sed -e 's/[^[:alpha:]]//g'

it will become:

toeder

how to make it back to original?

Last edited by elenatec; 09-07-2008 at 02:19 AM.. Reason: forget to put "" for string
# 2  
Old 09-07-2008
try with space between / /:

Code:
echo $name | sed -e 's/[^[:alpha:]]/ /g'

# 3  
Old 09-07-2008
name="toe der"
echo $name | sed -e 's/[^[:alpha:]]//g'

it will become:

toeder

then still if u do :
echo $name
it show: toe der
# 4  
Old 09-07-2008
Quote:
Originally Posted by RahulJoshi
name="toe der"
echo $name | sed -e 's/[^[:alpha:]]//g'

it will become:

toeder

then still if u do :
echo $name
it show: toe der
Could you please tell me your exact requirement?
# 5  
Old 09-07-2008
echo $name | sed -e 's/[^[:alpha:]]//g' > tmp1

if [ `more tmp1 | wc -m` -gt 1 ]; then
if [ `cat tmp1` != $name ]; then
echo -e "Not valid"
else
echo -e "valid"
fi
fi

something like this
i need to input and only accept character with spaces or whitout spaces.
# 6  
Old 09-07-2008
Error Help me.. Genius

Hi ,
I wish to know the virtual machine which is used to run AIX in my XP machine. Kindly help me... with necessary steps

thanks & regards
Thirumurugan
# 7  
Old 09-07-2008
Hi,

Welcome to the forum Smilie

Logically this should be a new post. Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can't remove spaces with sed when calling it from sh -c

The following command works echo "some text with spaces" | sh -c 'sed -e 's/t//g''But this doesn't and should echo "some text with spaces" | sh -c 'sed -e 's/ //g''Any ideas? (3 Replies)
Discussion started by: Tribe
3 Replies

2. Shell Programming and Scripting

How to prepend spaces using sed command..?

hi all , i had the below sed command to append header at the starting of my output file .... sed -i -e '1i saikumar suresh hemanth' output.txt i want to append spaces to the Name saikumar how can i append with in this command ....? (1 Reply)
Discussion started by: hemanthsaikumar
1 Replies

3. Homework & Coursework Questions

Alphabetical help.

1. The problem statement, all variables and given/known data: Find the first letter in alphabet from the input: Accept the input of a series of upper case alphabetic letters one at a time. The input ends with a 0. Find and display the first letter in alphabetic order. For example, input... (27 Replies)
Discussion started by: Ren_kun
27 Replies

4. Shell Programming and Scripting

sed with escapes AND spaces?

It's been covered in lots of places, and I have banged on it for about an hour and I am not making any headway on this particular string. A weather-related web page I want to monitor has text on the screen, but it changes. Right now, the page has "None issued by this office recently." but in 2... (4 Replies)
Discussion started by: Habitual
4 Replies

5. Shell Programming and Scripting

tr and sed remove spaces. how to stop this?

if the answer is obvious, sorry, I'm new here. anyway, I'm using tr to encrypt with rot-13: echo `cat $script | tr 'a-zA-Z' 'n-za-mN-ZA-M'` > $script it works, but it removes any consecutive spaces so that there is just one space between words. I've had this problem before while using sed to... (5 Replies)
Discussion started by: Trichopterus
5 Replies

6. Shell Programming and Scripting

How to Use Sed Command to replace white spaces with comma from between two fields - Mayank

SHELL SCRIPT Hi I have a file in the following format Mayank Sushant Dheeraj Kunal ARUN Samir How can i replace the white space in between and replace them with a comma?? The resultant output should be Mayank,Sushant Dheeraj,Kunal ARUN,Samir i tried using sed -e... (8 Replies)
Discussion started by: mayanksargoch
8 Replies

7. UNIX for Dummies Questions & Answers

How can I list the file under a directory both in alphabetical and in reverse alphabetical order?

How can I list the file under current directory both in alphabetical and in reverse alphabetical order? (1 Reply)
Discussion started by: g.ashok
1 Replies

8. UNIX for Dummies Questions & Answers

Tab spaces with sed

Anyone know how to represent tabs when doing subsitutions in sed? I have tried using \t but it doesn't seem to work. (11 Replies)
Discussion started by: handak9
11 Replies

9. Shell Programming and Scripting

sed over writes my original file (using sed to remove leading spaces)

Hello and thx for reading this I'm using sed to remove only the leading spaces in a file bash-280R# cat foofile some text some text some text some text some text bash-280R# bash-280R# sed 's/^ *//' foofile > foofile.use bash-280R# cat foofile.use some text some text some text... (6 Replies)
Discussion started by: laser
6 Replies

10. Shell Programming and Scripting

alphabetical order with out using sort command

hai, how can i sort a file alphabetically without using sort command (6 Replies)
Discussion started by: rahul801
6 Replies
Login or Register to Ask a Question