How to get rid of extra enter at the end???


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get rid of extra enter at the end???
# 1  
Old 08-14-2008
How to get rid of extra enter at the end???

Hi guys,

I want to automate a few tasks. For one of them, I need to get the output of a command and parse it to extract information I need: drbdadm create-md drbd0

The output is:

md_offset 48010952704
al_offset 48010919936
bm_offset 48009453568

Found ext2 filesystem which uses 18563076 kB
current configuration leaves usable 46884232 kB

==> This might destroy existing data! <==

Do you want to proceed?
[need to type 'yes' to confirm]

Now, I need to enter no at this stage so that I could get the size only. What I do is:

Quote:
test=`drbdadm create-md drbd0 | grep "current configuration leaves usable"` << MAYDAY
no

MAYDAY
But, this requires me to press enter at the command prompt before it finishes the execution.

How do I get rid of that extra enter? Anybody? please help!

Thanks
# 2  
Old 08-14-2008
Try:

Code:
test=`drbdadm create-md drbd0 << MAYDAY | grep "current configuration leaves usable" 
no

MAYDAY
`

# 3  
Old 08-15-2008
thanks alot! It worked!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed removing extra character from end

Hi, Searching through forum I found "sed 's/*$//'" can be used to remove trailing whitespaces and tabs from file. The command works fine but I see minor issue as below. Can you please suggest if I am doing something wrong here. $ cat a.txt upg_prod_test upg_prod_new $ cat a.txt |sed... (11 Replies)
Discussion started by: bhupinder08
11 Replies

2. UNIX Desktop Questions & Answers

To remove the extra spaces at the end of each line in a file

I have a file of about 10k records and eace line is having an extra space of 5 byte at the end.. Iwant to remove the extra spaces at the end of each line.. Can someone please help me out.. I tried using sed command and its not working... can someone please help me out. (3 Replies)
Discussion started by: rammohan
3 Replies

3. Shell Programming and Scripting

Loop logic, enter into respective IF as per enter input file name

have three big data file, however I just need to see the mentioned below one line form the all the file which has SERVER_CONNECTION Value File 1 export SERVER_CONNECTION=//dvlna002:10001/SmartServer File2 export SERVER_CONNECTION=///SmartServer File3 export... (1 Reply)
Discussion started by: Nsharma3006
1 Replies

4. Shell Programming and Scripting

my shell now adds extra space at end of each line!

Hi, Since today, with csh or tcsh, if I do 'ls files* > list', every lines end with an extra space! What happenned? What can I do to go back when there was no extra space? If I change to bash, there's no extra space. Thanks, Patrick ---------- Post updated at 03:19 PM... (1 Reply)
Discussion started by: trogne
1 Replies

5. Shell Programming and Scripting

Use of Begin IF ,END IF END not working in the sql script

Hi I have written a script .The script runs properly if i write sql queries .But if i use PLSQL commands of BEGIN if end if , end ,then on running the script the comamds are getting printed on the prompt . Ex :temp.sql After connecting to the databse at the sql prompt i type... (1 Reply)
Discussion started by: isha_1
1 Replies

6. UNIX for Dummies Questions & Answers

Enter data at end of a file

Hi All, I have a sample datafile: 5.1 5.2 0.8 6.1 What I want to do is create an additional 3 rows with the number "0.7". so that I now have: 5.1 5.2 0.8 6.1 0.7 0.7 (3 Replies)
Discussion started by: tintin72
3 Replies

7. Shell Programming and Scripting

awk get rid of space in end of field

Hello. I'm using a file to "grep" in a 2nd one (with awk) cat file1 2 first user 9 second user 1 third user (with a space after user) I want to get the line except the 1st field so I do : field=$(gawk '{$1 =""; print $0}' file | sed 's/^ //') It works but it deletes... (5 Replies)
Discussion started by: xanthos
5 Replies

8. Shell Programming and Scripting

How to enter a newline after every XML tag end?

Hi Guyz, I have an XML message in following format: I want my contents to be formatted in following order: i.e. I want a newline after every XML tag end. How to do this? Thnx in advance. (5 Replies)
Discussion started by: DTechBuddy
5 Replies

9. Shell Programming and Scripting

Need UNIX shell scripting end to end information

Hi, I would like to learn shell scripting in UNIX. Can any one please give me the support and share the information/documents with me. If any documents please post it to aswanikumar_nimmagadda@yahoo.co.in Thanks in advance...!!! (3 Replies)
Discussion started by: aswani_n
3 Replies
Login or Register to Ask a Question