Tried googling everywhere and I couldn't find anything. I'm trying to figure this out...how would one print out the actual \n char at the end of a line so that in the output file it comes out:
stuff stuff stuff \n stuff stuff stuff \n stuff stuff stuff \n stuff stuff stuff \n
Any and all help is appreciated.
I believe that all you would have to do is escape the slash in \n
in the following way: \\n
.
Here is a simple example:
ll | awk '{ printf "%s\\n\n",$1 }'
This should print the permissions column for each file in the current directory and after each line of input, a literal newline character \n
is inserted after which an actual newline is inserted.
The result should look something like this:
drwxrwxr-x.\n
-rw-rw-r--.\n
-rw-rw-r--.\n
-rwxrwxr-x.\n
-rwxrwxr-x.\n
drwxrwxr-x.\n
drwxrwxr-x.\n
As you can see, there is a literal \n
at the end of each line.
If you don't want any "real" newline characters and have all of your output on one line, you can remove the second \n
from the printf
statement:
ll | awk '{ printf "%s\\n",$1 }'
This will give you output very similar to what you mentioned in your question with a literal \n
appended to each input line:
\n-rwxrwxr-x.\ndrwxrwxr-x.\n-rw-rw-r--.\n-rwxrwxr-x.\ndrwxrwxr-x.\n-rw-rw-r--.\ndrwxrwxr-x.\n-rw-rw-r--.\n
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments