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 8542923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:11:01+00:00 2026-06-11T12:11:01+00:00

I have command line this: xclip -o -sel clip | sed -e ‘s/^ *\(.*\)+\?/\1/g’

  • 0

I have command line this:

xclip -o -sel clip | sed -e 's/^ *"\(.*\)"+\?/\1/g' | tr -d '\n' |
    sed -e 's/.\{,55\}/"&"+\n/g' |
    sed -e "2,$ s/^/$(seq 22 | xargs -I{} echo -n ' ')/" |
    sed -e '$ s/+$//' | xclip -sel clip

which format string in source code (I use it to format long string in javascript file – 55 and 22 are harcoded width and indent)

var foo = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"+
          ". Nulla sed dolor nisl, in suscipit justo. Donec a enim"+
          " et est porttitor semper at vitae augue. Proin at nulla"+
          " at dui mattis mattis. Nam a volutpat ante. Aliquam con"+
          "sequat dui eu sem convallis ullamcorper."

but when I copy past code inside parentheses var foo = foo.bar() I got this

var foo = foo.bar("Lorem ipsum dolor sit amet, consectetur adipiscing elit"+
                  ". Nulla sed dolor nisl, in suscipit justo. Donec a enim"+
                  " et est porttitor semper at vitae augue. Proin at nulla"+
                  " at dui mattis mattis. Nam a volutpat ante. Aliquam con"+
                  "sequat dui eu sem convallis ullamcorper."
)

New line after last quote, not the big deal but anybody know how can I remove that last new line?

  • 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-11T12:11:02+00:00Added an answer on June 11, 2026 at 12:11 pm

    Here’s one way of doing it, using awk. Setting RS (record separator) to the empty string tells awk to treat blank lines (i.e. two consecutive \n) as record separators. Setting FS to \n causes awk to take \n as field separators instead of white-space. (Setting RS to the empty string also causes \n to be used as a field separator, but we want to avoid having other whitespace recognized.) Finally, we set OFS (output field separator) to be the string we want between lines (closing quote, plus, linefeed, 22 spaces, opening quote) and setting ORS (output record separator) to an empty string causes awk to not write any linefeed at the end.

    I use fold to split the lines into 55-byte chunks instead of sed, partly because it seems tidier, and partly because, unlike sed, it doesn’t add a new line at the end of the input if there wasn’t one to start with.

    The seemingly redundant $1=$1 causes awk to recreate $0, which has the effect of using OFS as the output field separator between the fields. Otherwise, it is only used to separate separate print arguments.

    The first and last line are unchanged from the OP.

    xclip -o -sel clip | sed -e 's/^ *"\(.*\)"+\?/\1/g' | tr -d '\n' |
    fold -b -w55 |
    awk -vFS=$'\n' -vOFS="$(printf '"+\n%22s"' '')" \
        -vRS='' -vORS='' \
        '{$1=$1; print "\"" $0 "\""}' |
    xclip -sel clip
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query which on executing in my sql command line client executes
I have applet which I run in command line like this: C:\Program Files (x86)\Java\jdk1.6.0_21\bin\appletviewer.exe
I have this problem when I run SAS 9.2 on the command line on
This is a simple script I have written to test command line argument handling:
I have a bash script, that I run like this via the command line:
I have a command line like this: awk '$9 < 0.1' s_all_frq.txt | wc
I have a Sinatra::Base webservice which I want to start from a command line
Supose you have a command line executable that receives arguments. This executalbe is widechar
I have two command line with AWK which works perfectly: awk 'NR >=2 {for
I have a command line statement which works perfectly when manually typing it into

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.