Execution Error!

I am having output in this format..

-rw-r--r--
1
root
root
20
Jan
01
14:32
abc.txt
-rw-r--r--
1
root
root
40
Jan
01
14:32
abcd.txt
-rw-r--r--
1
root
root
60
Jan
01
14:32
abcde.txt
-rw-r--r--
1
root
root
80
Jan
01
14:32
abcdef.txt

I am trying to get into this format.

I am having output in this format..

-rw-r--r-- 1 root root 20 Jan 01 14:32 abc.txt
-rw-r--r-- 1 root root 40 Jan 01 14:32 abcd.txt
-rw-r--r-- 1 root root 60 Jan 01 14:32 abcde.txt
-rw-r--r-- 1 root root 80 Jan 01 14:32 abcdef.txt

Anyone help please...

To help we'd have to know what you did.. Then it is a good idea to give information about your OS ( OS and version ) and what shell you use

Welcome to forum

Did you try $ ls -l ?

Hello,

Following will help.

In case Input is as follows.

-rw-r--r--
1
root
root
20
Jan
01
14:32
abc.txt
-rw-r--r--
1
root
root
40
Jan
01
14:32
abcd.txt
-rw-r--r--
1
root
root
60
Jan
01
14:32
abcde.txt
-rw-r--r--
1
root
root
80
Jan
01
14:32
abcdef.txt
paste -d" " - - - - - - - - - < file-name 

Output will be as follows.

-rw-r--r-- 1 root root 20 Jan 01 14:32 abc.txt
-rw-r--r-- 1 root root 40 Jan 01 14:32 abcd.txt
-rw-r--r-- 1 root root 60 Jan 01 14:32 abcde.txt
-rw-r--r-- 1 root root 80 Jan 01 14:32 abcdef.txt
 

Thanks,
R. Singh

Thanks for the inputs...

if suppose what you posted on #1 is your input file following will work

$ awk '{ORS=NR%9==0?RS:FS}1' file
-rw-r--r-- 1 root root 20 Jan 01 14:32 abc.txt
-rw-r--r-- 1 root root 40 Jan 01 14:32 abcd.txt
-rw-r--r-- 1 root root 60 Jan 01 14:32 abcde.txt
-rw-r--r-- 1 root root 80 Jan 01 14:32 abcdef.txt

How did you generate the strange output in the first place? Was it ls -l | tr -s " " | tr " " "\n" or something?

You could:-

ls -l | tr -s " " | tr " " "\n" | while read perms
do
   read links
   read owner
   read group
   read size
   read d1
   read d2
   read d3
   read file

   echo "$perms $links $owner $group $size $d1 $d2 $d3 $file"
done

Or you could just ls -l and be done with it.

Am I missing something here?

Robin

In case you got such an output with a for loop

for word in `ls -l`
do
 echo "$word"
done

you better use a while loop

ls -l |
while read line
do
 echo "$line"
done

Please always quote $var: "$var" !

Hi, Sorry for the delay, by the way Thanks for the inputs..
Actually I am trying to open file that has been modified today (E.g: by using Today's date)
I have written in a script like:

dated=`date '+%b %d'` #I wanted to search like for e.g., if today's date is January 26 2014, then dated variable will have Jan 26.
fileslist=`ls -lt  | grep "$dated"`
for i in $fileslist
do
echo $i
done

I am willing to get the file names only and those should get opened.
Is there any other way I could do. Please help me out.

\ls -lt | grep "$dated" |
while read x x x x x x x x file
do
  [ -f "$file" ] || continue # skip directories
  echo "$file"
done

Or get the files from the last 24 hours:

find . -type d \! -name . -prune -o -mtime 0 -print |
while read file
do
  echo "$file"
done