Accepting A-Za-Z


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Accepting A-Za-Z
# 8  
Old 10-14-2010
Since you are using quotes where there should not be any since they are not part of the search string. Also in you replacement text you left out the space so it would be a replacement, not an append. Thirdly there is no g flag, so the replacement only happens once per line.

Try:
Code:
sed 's/ /&ABC/g'

# 9  
Old 10-14-2010
I have output such as

(SPACEBEFORE->)9
10
11

There is a space before the 9 and I cannot figure out how to remove it with sed.

If I do sed s/ /&abc/g

my output should be:
abc9
10
11
Correct?

...

If I do sed s/ //g
It just removes the entire line and leaves an empty line before the 10.
# 10  
Old 10-14-2010
But you send you wanted to
Quote:
add ABC at the end of every blank space
, in other words, to append it. If you want to replace each space you should use :
Code:
sed 's/ /ABC/g'

Don't forget the quotes, they are important.

Be careful with spaces though, they could be tabs (\t)...
# 11  
Old 10-14-2010
Quote:
Originally Posted by Scrutinizer
But you send you wanted to , in other words, to append it. If you want to replace each space you should use :
Code:
sed 's/ /ABC/g'

Don't forget the quotes, they are important.

Be careful with spaces though, they could be tabs (\t)...
I think the problem I am having is that they are tabs Smilie
# 12  
Old 10-14-2010
Quote:
Originally Posted by puttster
I have output such as

(SPACEBEFORE->)9
10
11

There is a space before the 9 and I cannot figure out how to remove it with sed.

If I do sed s/ /&abc/g

my output should be:
abc9
10
11
Correct?

...

If I do sed s/ //g
It just removes the entire line and leaves an empty line before the 10.
Code:
# sed 's/ 9//' file

--> delete all line before 10
Code:
# sed 's/ //' file

--> delete space every lines just one time
Code:
# sed 's/ //g' file

--> delete all spaces every lines all time
Code:
# sed 's/ /&9/g' file

--> change all spaces every lines with space+9 (why ? because our string is space -> that matches --> & symbol)
This User Gave Thanks to ygemici For This Post:
# 13  
Old 10-14-2010
Quote:
Originally Posted by puttster
I think the problem I am having is that they are tabs Smilie
then try:
Code:
's/[ \t]*/ABC/'

to replace any space character before the first non-space character with ABC
# 14  
Old 10-14-2010
Why is it that when I take data and store it in a variable with grep, that it creates a space after every single piece of data except for the first chunk?
For example,

my output is
400
500
600
700
800
900
I store 400 500 600 700 800 900 in A by doing

A=`(i used grep to single out this set of data )|head -6|awk '{print $6}'`
( $6 is the 6th column within my data set )
I echo $a

and only 900 is shown in A, however.... if I do -5 it->( outputs 800 ) or -4 it ->( outputs 700 ) -3 it ->( outputs 600 ).... why is that?



Also

My numbers do have something in front of them Than I cannot explain...
I can only get my code to work with the FIRST line ( 100 )and the first line has no spaces or anything in front of it.
Further explanation...

NOSPACESHERE100
_200
_300
_400
_500
etc...
there are spaces before 200 300 400 500 which are making this stressful... are they carriage returns...tabs?

Last edited by puttster; 10-14-2010 at 07:12 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parameter not accepting in awk

In below script parameterwhich i am passing to awk function is not working.Not sure why its not accepting parameter.Please tell me how to pass parameter to the awk function.Please check the below script. #!/bin/ksh dummy_file=/etlapps/dev/data/sub_servicer_data/ScriptLogs/emp.txt fields=5... (2 Replies)
Discussion started by: katakamvivek
2 Replies

2. Shell Programming and Scripting

script accepting password

Hi friends, I am very new to Unix scripting and having some difficulty in my first shell script. I have written a simple shell script to upload an artifact to a remote machine on the network. echo "Uploading the artifact" scp app.war username@remotemochine.domainname.net:/home/deployables... (3 Replies)
Discussion started by: prashdeep
3 Replies

3. Shell Programming and Scripting

accepting passwords in shell programming

how do i accept a password like input through keyboard using shell script? i dont know the command for doing so. (5 Replies)
Discussion started by: kz2013
5 Replies

4. Shell Programming and Scripting

Accepting Input regardless of Case

Hi I am trying to get my script to accept input regardless if the person enters a or A. here is the portion of the code where I get the input. echo -n 'Please enter your choice:' # prompt user for input. read reply # read input echo case $reply in #... (2 Replies)
Discussion started by: DualPandas
2 Replies

5. Shell Programming and Scripting

Help with Accepting Directories as an Argument

I'm doing a script where you are suppose to start off in accepting one or more directory as an argument. How do i do this? Sorry for the nub question. (2 Replies)
Discussion started by: LinuxUser232331
2 Replies

6. Shell Programming and Scripting

reg accepting password

Hi, I want to login to many systems and password should be taken automatically from a file(login is working but password is not accepting). Any help on this is appreciable . My code. for i in `cat /tmp/tes ` ====>tes file contain list of hosts > do ssh $i > perl prog.pl >... (1 Reply)
Discussion started by: rogerben
1 Replies

7. UNIX for Dummies Questions & Answers

accepting input date

I how do i accept a input date in script which is lesser than a specified day? ex: to accept a date less than or equal to 100 days(from today).?:( Thanks for the help in advance.:) (1 Reply)
Discussion started by: abhi_123
1 Replies

8. Shell Programming and Scripting

Not able to display the value I am accepting as an argument

Hi, I am new to UNIX. I am facing some problem here. #! /usr/bin/ksh currDate = $1 export currDate; echo " Date is $currDate" when I run this script, it says : currDate not found. Can anybody point out the mistake please. --mahek (3 Replies)
Discussion started by: mahek_bedi
3 Replies

9. HP-UX

Oracle not accepting new connections

Hi UNIX guru's, Have recently upgraded Oracle from 8i to 10g on an HP-UX (RISC) 11.11 box. At least twice a day the database stops accepting incoming connections and the following errors are observed in the various logs. The box needs to be rebooted to get everything going again. The... (4 Replies)
Discussion started by: mat_cottrell
4 Replies

10. Shell Programming and Scripting

Accepting User Input

I'm just starting out with UNIX and have figured some stuff out. I just need some help with accepting user input on the command line. For instance, I created a number counter that counts down from any positive hard coded number. But, I want the commnad line line to read "Countdown 20" where 20... (1 Reply)
Discussion started by: scott78
1 Replies
Login or Register to Ask a Question