LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-24-2020, 01:30 AM   #1
blueray
Member
 
Registered: Feb 2020
Location: Bangladesh
Distribution: Debian, Ubuntu, Linux Mint
Posts: 136

Rep: Reputation: 2
Text Above and Bellow Selected Lines


I am using Geany.

These is a option Edit > Format > Send Selected To > Set Custom Commands

Here, for example if I want to sort selected text, I just use sort command.

What I want this (Set Custom Commands) to do is put "...." above and bellow my selected line/s.

For Example if I select the following lines,

Code:
touch sample_file.txt
ls
rm sample_file.txt
ls
Then go to Edit > Format > Send Selected To > MyCommand

I am expecting to get

Code:
....
touch sample_file.txt
ls
rm sample_file.txt
ls
....
Is there any way I can achieve this?
 
Old 02-24-2020, 08:35 PM   #2
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 360

Rep: Reputation: 170Reputation: 170
Try setting this command
Code:
sed '1 s/^/....\n/; $ s/$/\n..../'
 
1 members found this post helpful.
Old 02-25-2020, 06:53 AM   #3
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,599

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546
You could use awk's BEGIN/END for this.

Code:
$ cat 4175670153.txt | awk 'BEGIN {print "...."} {print $0} END {print "...."}'
....
touch sample_file.txt
ls
rm sample_file.txt
ls
....
 
1 members found this post helpful.
Old 02-25-2020, 09:06 PM   #4
blueray
Member
 
Registered: Feb 2020
Location: Bangladesh
Distribution: Debian, Ubuntu, Linux Mint
Posts: 136

Original Poster
Rep: Reputation: 2
Thank you very much.

Code:
sed '1 s/^/....\n/; $ s/$/\n..../'
or,

Code:
awk 'BEGIN {print "...."} {print $0} END {print "...."}'
Both Works.
 
Old 03-01-2020, 11:06 PM   #5
blueray
Member
 
Registered: Feb 2020
Location: Bangladesh
Distribution: Debian, Ubuntu, Linux Mint
Posts: 136

Original Poster
Rep: Reputation: 2
Few more solutions that worked for me:

Code:
echo -e "....\n$(</dev/stdin)\n...."
or,

Code:
 cat <(printf "....\n") - <(printf "....\n")
or,


Code:
echo "....";cat -;echo "....";
The last one is not fully tested though.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Which html WYSIWYG is responsible for creating this? (see bellow, pls.) hearthstone Linux - Software 6 06-10-2013 08:06 PM
[SOLVED] mmap: getting SIGBUS when writing to a position that is bellow what I requested eantoranz Programming 2 08-09-2012 10:04 AM
I need a script to Delete Selected BackupFiles and Restore selected backup file finalwar Linux - Newbie 3 07-20-2010 02:10 AM
LAMP installation with apache(2.2 or above),php(5.1.4 or above)),mysql(4 or above) mobquest Linux - Newbie 2 08-31-2009 12:01 AM
Sed command to print matching lines and 2 lines above.. DX398 Programming 12 10-01-2008 08:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration