Launch nano editor passing piped command

nano editor commands
nano tutorial
nano linux

this is a curiosity. Can i start nano editor from bash, passing a piped command? this is my situation: I've a log file with dates formatted in tai64. For print my file i launch:

$> cat /var/log/qmail/current | tai64nlocal

that print what i want. but i want to view this in nano or another editor in one command. for example:

$> cat /var/log/qmail/current | tai64nlocal > nano

but this doesn't work. Any suggestion? Thanks in advance

Use process substitution:

nano <(cat /var/log/qmail/current | tai64nlocal)

Also, you don't need to use cat

nano <(tai64nlocal < /var/log/qmail/current)

Piped input to nano, The feature wasn't added until version 2.2. http://www.nano-editor.org/dist/v2.2/​TODO. For version 2.2: Allow nano to work like a pager (read from stdin) [DONE]. Running Nano. You can run nano in two ways. To open nano with an empty buffer, just type in “nano” at the command prompt. You can also use the following syntax: nano /path/to/filename. Nano will follow the path and open that file if it exists. If it does not exist, it’ll start a new buffer with that filename in that directory.

if you want to nano to open stdin use dash-notation (-):

echo "foo" | nano -

in your case this would translate to

cat /var/log/qmail/current | tai64nlocal | nano -

GNU nano, Besides basic text editing, nano offers many extra features, like an interactive This allows nano to write to named pipes: it will start with a blank buffer, and will rather than having to pass command-line options to get the desired behavior. Unlike vi, nano is a modeless editor, which means that you can start typing and editing the text immediately after opening the file. To move the cursor to a specific line and character number, use the Ctrl+_ command. The menu on the bottom of the screen will change.

It didn't work because you are not using pipes. You are using a redirect which works slightly different.

| vs >

By doing

 cat /var/log/qmail/current | tai64nlocal > nano

You are piping cat's stdout to tai64nlocal stdin. Then you redirect it's stdout to a filestream, in this case a file named nano in your pwd.

Based on what you wanted, it partially works because the tai command does both printing and echoing to stdout.

Older versions of nano do not support being piped to though. This was introduced in nano 2.2.

You would do

 Command | nano -

The single dash tells nano to open stdin as a pager, like more or less would.

nano Command Manual, How to wrap your code into a file and run it from the command-line Let's use the nano text editor to create a shell script named hello.sh . hello.sh script to read in the argument (in this case, someone's name) that we pass into it? Then modify hello.sh like so, piping the output through tr to replace lowercase letters with  Nano is a simple, modeless, WYSIWYG command-line text editor included in most Linux installations. With a simple easy to use interface, it is a great choice for Linux beginners. With a simple easy to use interface, it is a great choice for Linux beginners.

davymartu's command "nano < ( cat /var/log/maillog | tai64nlocal )" generates a syntax error because of the space between "<" and "(". If the space is removed, as it is in konsolebox's examples, the command will execute.

Creating basic shell scripts, The command nano middle.sh opens the file middle.sh within the text editor '​nano' This is a variation on the pipe we constructed earlier: it selects lines 11-​15 of the file octane.pdb . Our shell is called bash , so we run the following command: $2 and $3 for the number of lines to be passed to head and tail respectively:. nano will read one command per line. Options in nanorc files take precedence over nano’s defaults, and command-line options override nanorc settings. Also, options that do not take an argument are unset by default.

Shell Scripts – The Unix Shell, Making nano accepting previous piped output as a file path · linux pipe nano. When I run the following command in linux: find / -iname httpd.conf. Treat any name given on the command line as a new file. This allows nano to write to named pipes: it will start with a blank buffer, and will write to the pipe when the user saves the "file". This way nano can be used as an editor in combination with for instance gpg without having to write sensitive data to disk first.

Making nano accepting previous piped output as a file path, GNU nano is a popular command line text editor that is included in most Linux distributions. To open a file, pass the filename as an argument:. This manual page briefly documents the nano command. nano is a small, free and friendly editor which aims to replace Pico, the default editor included in the non-free Pine package. Rather than just copying Pico’s look and feel, nano also implements some missing (or disabled by default) features in Pico, such as "search and replace" and "go to line number".

How to Use Nano Text Editor Commands in Linux, When you run it with no arguments, it is not very useful—it lists only You can also pipe any command to the less program (such as ps -ef | less) so If you try to kill a process and it doesn't seem to cooperate, you can force the process to die by passing the -9 option to kill . To edit a file with nano, type nano followed by. Most Linux distributions include a text editor called nano as a standard utility. It's part of a family of text editors that includes the more robust (but significantly more complex) vi and emacs. For most uses, nano is easy to use and it doesn't require a significant learning curve.

Comments
  • # nano < ( cat /var/log/maillog | tai64nlocal ) returned me: -bash: syntax error near unexpected token `(' why?
  • I guess you're not running bash or that you're running bash in POSIX mode (called with sh). Process substitution is only possible in real bash mode. umläute's answer is actually more compatible.
  • Can you suggested me any solution? Maybe this error appear only in putty ssh terminal?
  • @davymartu When you're on the terminal, try to run exec bash -l, then run the command again.
  • @davymartu I think your terminal simply launches /bin/sh by default instead of /bin/bash. There should be a way to configure that.
  • echo "foo" | nano - give me: Ricevuto SIGHUP o SIGTERM Buffer scritto su -.save.5 and don't open nano
  • @davymartu i only get this error if i run echo "foo" | nano rather than echo "foo" | nano - (note the trailing -)