LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Nano: How to copy entire non-wrapping line? (https://www.linuxquestions.org/questions/linux-newbie-8/nano-how-to-copy-entire-non-wrapping-line-4175466514/)

theboyk 06-18-2013 12:14 PM

Nano: How to copy entire non-wrapping line?
 
Hello.

I'm working on some documentation and I need to copy some tasks from my crontab and paste them into another file. The problem, when I view the crontab with Nano, it's not wrapping the lines and is truncating it with a trailing $ when the line length is longer than the width of the terminal window (like it's supposed to).

So, I'm wondering if anyone knows how I can copy the complete (truncated) line from the crontab using Nano so I can then paste it into another document?

Thanks,
Kristin.

szboardstretcher 06-18-2013 12:24 PM

The $ lets you know that the line is continuing. Go to the line and scroll right.

If you were asking how to make it line wrap -- just press CTRL-J (Justify)

theboyk 06-18-2013 12:34 PM

Yea, I knew if I scrolled to the right of the $, it would continue displaying the line, but still wasn't able to copy the entire line that way. But, justifying the line worked perfectly!

That said—what exactly is Justify doing in terms of how the file is built? I know line-wrapping within the crontab isn't typically used (because the line wrap = new line and errors out when saving the crontab), but would the same thing happening if using Justify?

I typically end up going into vi to edit the contab tasks, but I'm slightly more comfortable in nano, so if the Justify option on a long line doesn't have any negative implications, I might consider doing that going forward...

Thanks!

273 06-18-2013 12:44 PM

If you just want to duplicate a line under itself in the same file, for example, then just hit Ctrl+k then Ctrl+u twice.
Not sure whether that helps.

theboyk 06-18-2013 12:45 PM

Quote:

Originally Posted by 273 (Post 4974280)
If you just want to duplicate a line under itself in the same file, for example, then just hit Ctrl+k then Ctrl+u twice.
Not sure whether that helps.

No, I'm looking to copy the line to the Clipboard (OS X) so I can then paste it into a text file. Thanks though.

273 06-18-2013 12:50 PM

Quote:

Originally Posted by theboyk (Post 4974281)
No, I'm looking to copy the line to the Clipboard (OS X) so I can then paste it into a text file. Thanks though.

Though that might be the case, sorry. I'd be interested in a solution too.

szboardstretcher 06-18-2013 12:52 PM

Offhand i do not know. But testing should be straight forward. Create a temp file with those lines, justify it, then cat the file and see if everything is ok. And testing the copy and paste functionality is just as easy to test. Justify it, then copy and paste it.

273 06-18-2013 12:58 PM

I just tried justify on my .conkyrc (file with long lines I have handy) and it did nothing. I'm a little stumped now.

theboyk 06-18-2013 01:21 PM

Yea, the Justify hard-returns line-breaks, but all good. Just won't save the file after justifying it. 8)

allend 06-18-2013 03:45 PM

With nano, you could read the file containing the long lines into your document (Ctrl-R) and then delete what you do not need.

273 06-18-2013 03:55 PM

Quote:

Originally Posted by allend (Post 4974400)
With nano, you could read the file containing the long lines into your document (Ctrl-R) and then delete what you do not need.

Good call! TI could be excessive in some circumstances but it's a working solution, thanks. I didn't know this was something I wanted to do before I read this thread.


All times are GMT -5. The time now is 03:34 PM.