1

I'm using echo to output text and curl to get my ip from a website:

echo -n "IP: "; curl ifconfig.co/x-real-ip; echo -e "\b test"

what I noticed is that when the curl command is executed it automatically changes to a new line, and with the escape \b i thought maybe i could backspace to the previous line and output some more text there. Though that is not working apparently. Is there any way to do that?

4
  • 1
    echo "IP: `curl other args` test" Commented Jul 4, 2015 at 22:20
  • this outputs everything in the " " as a string.. no command is executed among those. Commented Jul 4, 2015 at 22:34
  • impossible. back tick will be substituted inside of double quotes. what environment are you running bash in? Commented Jul 4, 2015 at 22:37
  • Replace ifconfig.co/x-real-ip by network-science.de/tools/myip. Commented Jul 4, 2015 at 22:44

2 Answers 2

1

Once the line is incremented, echoing a backspace will not help. Try this:

printf "IP: $(curl -s ifconfig.co/x-real-ip) anything-else\n"
Sign up to request clarification or add additional context in comments.

4 Comments

xargs used on curl returns the whole process and info of obtaining the information through the internet, download/upload speed, total size, received! thanks though for the quick answer!
@quelotic: second try please :)
same thing happens, feels strange cause all the download info of the curl is showing right before the printf starts printing... the lines print correctly on my screen except that now I get all that useless information! Its progress whatsoever! :)
all i needed after all was the silent mode on curl "curl -s" thanks a bunch :)
1

This should work:

ip=$( curl -s ifconfig.co/x-real-ip ); echo -n "IP: $ip "; echo "more stuff" 

With ip stored in variable, it is possible to avoid printing newline using the -n parameter.

1 Comment

thanks for the answer! didn't try that one but looks like its working quite good! all i needed was the -s for silent mode!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.