1

Is it possible?

For example, say I want to run the command ll:

My output would look something like this:

josh@zeitgeist ~ ll
total 41148
drwxr-xr-x 42 josh josh     4096 Aug  4 22:52 ./
drwxr-xr-x  4 root root     4096 Jul  9 21:18 ../
-rw-rw-r--  1 josh josh  3523718 Jul 11 00:17 2017-07-11-001710_3840x2160_scrot.png

but I want it to look like this:

josh@zeitgeist ~ ll
XXXtotal 41148
XXXdrwxr-xr-x 42 josh josh     4096 Aug  4 22:52 ./
XXXdrwxr-xr-x  4 root root     4096 Jul  9 21:18 ../
XXX-rw-rw-r--  1 josh josh  3523718 Jul 11 00:17 2017-07-11-XXX001710_3840x2160_scrot.png

I already know about using PS1='XXX' to change the prompt; is there a way to change every line of the output that gets displayed, specifically in the terminal(not changing the output and putting it in a file)?

I would like to do this to have a unified line of characters going down the left side of my terminal.

jww
  • 97,681
  • 90
  • 411
  • 885
suhmedoh
  • 103
  • 1
  • 4
  • 2
    What are you trying to accomplish with this? Are you trying to easily tell your terminals apart? – that other guy Aug 05 '17 at 03:11
  • `I would like to do this to have a unified line of characters going down the left side of my terminal` this is not clear, why would you want that? – marekful Aug 05 '17 at 03:47

4 Answers4

4

You can easily do it with sed:

ll | sed 's/./XXX&/'
whoan
  • 8,143
  • 4
  • 39
  • 48
  • I'm been using sed for years. Previous to find this answer just now, I've had complicated functions perform while read loops. This sed 'trick' is utterly amazing! – bgStack15 Aug 23 '17 at 00:13
1

Prepend XXXto all lines including empty lines.

ll | sed 's/^/XXX/'

Edit: After changing your PS1 you can invoke the solution for all commands using

bash | sed 's/^/XXX/'
Walter A
  • 19,067
  • 2
  • 23
  • 43
0

You could do something like this I suppose:

while read; do echo "xxx $REPLY"; done < <(ls -l)

Not really sure what the purpose of this would be though.

I0_ol
  • 1,054
  • 1
  • 14
  • 28
0

Using awk:

$ ll|awk '$0="XXX"$0'
James Brown
  • 36,089
  • 7
  • 43
  • 59