Execution Error!


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Execution Error!
# 1  
Old 01-22-2014
RedHat Execution Error!

I am having output in this format..
Code:
-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..
Code:
-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...

Moderator's Comments:
Mod Comment Please use code tags next time...

Last edited by vbe; 01-22-2014 at 10:53 AM..
# 2  
Old 01-22-2014
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
# 3  
Old 01-22-2014
Welcome to forum

Did you try $ ls -l ?
# 4  
Old 01-22-2014
Hello,

Following will help.

In case Input is as follows.
Code:
-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

Code:
paste -d" " - - - - - - - - - < file-name

Output will be as follows.

Code:
-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

Last edited by RavinderSingh13; 01-22-2014 at 11:01 AM.. Reason: added Input
# 5  
Old 01-22-2014
Thanks for the inputs...
# 6  
Old 01-22-2014
if suppose what you posted on #1 is your input file following will work

Code:
$ 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

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

You could:-
Code:
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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Stop script execution, when we encounter error

Team, Im new to shell scripting please help in below issue: Considering scenario i have 1.sql,2.sql,3.sql and 4.sql . If my second script fails my loop should come out and should not execute 3.sql and 4.sql. Here is my code. #! /bin/bash echo "exit" | user/password | grep Connected >... (4 Replies)
Discussion started by: preethi87
4 Replies

2. AIX

Error while script execution - 0403-029 there is not enough memory available now

Hi, I am executing a shell script on AIX box where I need to list all the files in the file system and then do some other tasks with them. I am able to do this successfully on HP-UX and Linux boxes but I get the following error after 10-15 seconds when I try to execute the script on an AIX box. ... (6 Replies)
Discussion started by: Adyan Faruqi
6 Replies

3. Programming

Solr--Basic Example execution error

Hello , I am new bee to Solr and trying to run sample example for solr . java -Durl=http://locahost:8983/solr/update -jar post.jar books.csv Error SimplePostTool version 1.5 Posting files to base url http://locahost:8983/solr/update using content-type... (3 Replies)
Discussion started by: Tomlight
3 Replies

4. Shell Programming and Scripting

Syntax error in sh script execution

Script: #!/sbin/sh echo "Welcome to my First Script" echo "Enter a word" read PASS if then echo "You are correct" elif then echo "Thats incorrect" else echo "Bye" fi When i run the script shell says: Syntax error at line 7:'elif' is not expected I ran through some old posts and... (3 Replies)
Discussion started by: Amit Kulkarni
3 Replies

5. Shell Programming and Scripting

Execution of shell script returns error 127

Hi All, While running shell script i got following output. interpreter "usr/bin/ksh" not found sh: step1.sh: not found. ldnhpux | oracle >echo $? 127 - Running command "which ksh" retruns "usr/bin/ksh". - I found some information on web stating to remove extra carriage return chars,... (8 Replies)
Discussion started by: RuchirP
8 Replies

6. Shell Programming and Scripting

Execution error with awk script

Hi, I run an awk script and I got the error attached below: here are the lines that the compiler point to as an error: duration = timeEnd1-timeBegin1; print "Transmission: type of traffic " flow1 ; print “ - Total transmitted bits = ” totalBits1 ” bits”; print “ - duration = ”... (2 Replies)
Discussion started by: ENG_MOHD
2 Replies

7. Shell Programming and Scripting

Expect Issue Serial Forground Execution vs Concurrent Background Execution

I have an expect script that interrogates several hundred unix servers for both access and directories therein using "ssh user@host ls -l /path". The combination of host/path are unique but the host may be interrogated multiple times if there are multiple paths to test. The expect script is run... (2 Replies)
Discussion started by: twk
2 Replies

8. Shell Programming and Scripting

SolarisCron job perl script execution error

Hi, I want to run a crontab job on solaris10.5. I have configured the crontab accordingly 10 * * * * /scripts/dbalter.pl >> /scripts/cronout.txt.However this does not work .Then I go to /var/mail/root and find an error in the output:... (4 Replies)
Discussion started by: sonu2die4
4 Replies

9. Shell Programming and Scripting

error during the execution of script

Hi, I have a cron job which executes daily once 9 PM. The script is like if then TYPE=OC elif then TYPE=i elif then TYPE=mmc elif then TYPE=CB elif then TYPE=oth fi (1 Reply)
Discussion started by: surjyap
1 Replies

10. Programming

metamail execution error

Hi. I´m have installed the metamail from skunkware and when I´m trying to use mailto (the complete script is bellow), I got this message: # mailto To: test@bla.com Subject: test ~/2048000 Set splitsize to 2048000 ~* Please choose which kind of data you wish to insert: 0: A raw file,... (2 Replies)
Discussion started by: ahnishimi
2 Replies
Login or Register to Ask a Question