Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9189599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:16:21+00:00 2026-06-17T20:16:21+00:00

I want convert this text: qa-ops01.mysite.com /dev/mapper/sys-home 58G 26G 30G 47% /home /dev/mapper/sys-tmp 3.9G

  • 0

I want convert this text:

qa-ops01.mysite.com
/dev/mapper/sys-home   58G   26G   30G  47% /home
/dev/mapper/sys-tmp   3.9G  2.3G  1.5G  61% /tmp
qa-ops02.mysite.com
/dev/mapper/sys-home   58G   26G   30G  47% /usr
/dev/mapper/sys-tmp   3.9G  2.3G  1.5G  61% /var
qa-ops03.mysite.com
/dev/mapper/sys-home   58G   26G   30G  47% /lib
/dev/mapper/sys-tmp   3.9G  2.3G  1.5G  61% /etc

to this one:

qa-ops01.mysite.com /dev/mapper/sys-home   58G   26G   30G  47% /home
qa-ops01.mysite.com /dev/mapper/sys-tmp   3.9G  2.3G  1.5G  61% /tmp  
qa-ops02.mysite.com /dev/mapper/sys-home   58G   26G   30G  47% /usr
qa-ops02.mysite.com /dev/mapper/sys-tmp   3.9G  2.3G  1.5G  61% /var   
qa-ops03.mysite.com /dev/mapper/sys-home   58G   26G   30G  47% /lib
qa-ops03.mysite.com /dev/mapper/sys-tmp   3.9G  2.3G  1.5G  61% /etc

I have used

cat FILE |sed 'N;s/.com\n//'

Is there anyway to achieve this, or should I just write the If… Then…

Thanks everybody for the answers 😀 (you always show me new things :D)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:16:22+00:00Added an answer on June 17, 2026 at 8:16 pm

    The answer by potong is almost correct; it only handles one server, rather than multiple servers, but the change required is small.

    $ sed -e '/^[^ ]*$/{h;d;}' -e 'G; s/\(.*\)\n\(.*\)/\2 \1/' data
    qa-ops01.mysite.com /dev/mapper/sys-home   58G   26G   30G  47% /home
    qa-ops01.mysite.com /dev/mapper/sys-tmp   3.9G  2.3G  1.5G  61% /tmp
    qa-ops02.mysite.com /dev/mapper/sys-home   58G   26G   30G  47% /usr
    qa-ops02.mysite.com /dev/mapper/sys-tmp   3.9G  2.3G  1.5G  61% /var
    qa-ops03.mysite.com /dev/mapper/sys-home   58G   26G   30G  47% /lib
    qa-ops03.mysite.com /dev/mapper/sys-tmp   3.9G  2.3G  1.5G  61% /etc
    $
    

    The script is in two parts, identified by the two -e options. The first part identifies server names; those lines contain no spaces (hence /^[^ ]*$/ looks for a line with no spaces), and copies the line into the hold space (h) and then deletes it (d) and continues with the next line. The second part of the script is only exercised on lines that contain spaces. It appends the content of the hold space to the pattern space after a newline (G); then it splits the line into ‘everything up to the newline’ and ‘everything after the newline’, and switches them so that the ‘after’ (\2) comes first, then a space, then the ‘before’ (\1).

    This uses the classic sed regular expressions; it was tested on Mac OS X (10.7.5) with both the BSD sed and also with GNU sed without change. GNU sed has options such as -r to change the interpretation of regexes which would save you a few backslashes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this php code saved in text file, I want to convert this
I want to convert a byte into Boolean. This is the code: String text
Having a rough time getting this working. I convert this text: [url]http://www.stackoverflow.com[/url] to <a
In R, I want to convert t1 <- c('this.text', 'next.text') this.text next.text to 'ThisText'
I want to convert this linear loop into a concurrent one: for(Item item :
i want to convert this array Array ( [2] => Array ( ) [4]
i want to convert this string into DateTime. Tue Aug 19 15:05:05 +0000 2008
i have an array and i want to convert this array in comma seprated
Say I have the string 1,2,3,4,5 and I want to convert this to an
I have a date in String format, mm/dd/yyyy I want to convert this to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.