Question: I'm using `find /usr/local -ls`. It's showing like below:

```
19799045 4 drwxr-xr-x 9 hduser root 4096 Feb 23 11:00 /usr/local 

```

I have to make the data comma-separated like below:

```
19799045,4,drwxr-xr-x,9,hduser,root,4096,Feb 23 11:00,/usr/local 

```

How to do it?

Answer: 
As a general programming principle, it is much easier to generate data in the format you need than it is to generate it in the wrong format and then translate it.

Since you are already using the non-standard non-portable `-ls` primary anyway, you might just as well use `-printf` instead, if your implementation of `find` has it. Something like this should get you closer to what you need:

```
find /usr/local -printf '%i,%b,%M,%n,%u,%g,%s,%Tc,%h/%f'

```
You can use this lovely awk command:

```
find /usr/local -ls | awk '{s="";for(i=1;i<=7;i++)s=s$i",";s=s$8" "$9" "$10;for(i=11;i<=NF;i++)s=s$i;print s}'

```

If you prefer to put the awk command in a file, or actually read it:

```
{
  s = ""
  for (i = 1; i <= 7; i++)
    s = s$i","
  s = s $8" "$9" "$10","
  for (i = 11; i <= NF; i++)
    s = s$i" "
  print s
}

```

This will slightly alter the filename at the end if it contains multiple consecutive spaces, or whitespace characters other than plain spaces. That's just part of the fun when you parse output that wasn't designed to be parsed using tools barely suited to the task.