UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2010-11-17 06:17 AM

Toni
Guest

ls unix command

Hello,

i am using the code :

ls -1

and i would like to know how can i add at the beginning of each result the + character . for example i would like the output to look like :
+final.doc
+music.txt
+old.pdf

which command do i need to use ?


Thank you .

#2 2010-11-17 02:23 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: ls unix command

That sounds like an odd thing to want to do...  What are you trying to accomplish, exactly?

But, there are various ways you could do it...  Personally, off the top of my head, I'd probably reach for good old "sed":

ls -1 | sed -e 's/^/+/'

Though, really, once you've got a pipe in there, the "-1" is no longer needed, since that's the default mode when piping ls's output...

Offline

Board footer

Powered by FluxBB