awk+cat


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers awk+cat
# 15  
Old 10-20-2011
vbe, i understand this but It just does not my while part...it just prints until end of my ls+awk..do you get me? it does not show the file content...i used your code just now and got this:

??? ---> should be the content of the files!!!!! I have tried many other things myself, its simple but it just does not work!

Dec 30 2008 test0.txt ???
Mar 4 2009 test1.txt ???
# 16  
Old 10-20-2011
Post a sample of your ll -tr output, please, it may not be what we thought it was.
# 17  
Old 10-20-2011
Code:
ant:/home/vbe/z01 $ ll                                                            
total 64
drwxrwxr-x   2 vbe        bin             96 Oct 20 18:09 .
drwxr-xr-x  55 vbe        bin          29696 Oct 20 18:08 ..
-rw-rw-r--   1 vbe        bin             11 Oct 20 18:09 001
-rw-rw-r--   1 vbe        bin             19 Oct 20 18:09 002
-rw-rw-r--   1 vbe        bin             15 Oct 20 18:09 003
ant:/home/vbe/z01 $ cat *
wefwkjhf l
mndfsèw  fewk wehf
qwpd dsnckjhdf
ant:/home/vbe/z01 $ ll -tr  | awk '{print $6, $7, $8, $9}'| while read tet tit>
Oct 20 18:08 ..
Oct 20 18:09 001
Oct 20 18:09 002
Oct 20 18:09 .
Oct 20 18:09 003
ant:/home/vbe/z01 $ ll -tr  *| awk '{print $6, $7, $8, $9}'| while read tet ti>
wefwkjhf l
mndfsèw  fewk wehf
qwpd dsnckjhdf
ant:/home/vbe/z01 $

Sorry fellows I'm leaving for today, terrible headache...
# 18  
Old 10-21-2011
@messi : Final one .. have a try ..
Code:
$ ll -tr | awk '{print "echo \""$6,$7,$8,$9"\" ; cat "$9}' | sh | paste -d' ' - -
Oct 20 14:12 file1 hi
Oct 20 14:12 file2 hi
$

# 19  
Old 10-21-2011
Jayan, it did not work! it does not cat. the result is below:

Code:
echo "Mar 4 2009 text1.txt" ; cat text1.txt echo "Apr 10 2009 text2.txt" ; cat text2.txt

---------- Post updated at 03:09 AM ---------- Previous update was at 03:04 AM ----------

sample of my ll -tr:
Code:
ll -tr
total 448
-rw-rw-rw-   1 messi   ops              3 Oct 18 11:48 text1.txt
-rw-rw-rw-   1 messi     sp               3 Oct 20 08:28 text2.txt

then inside the text1...n.txt is one word only in first line! i want to cat it after 6,7,8,9$.
I hope its clear.

---------- Post updated at 08:26 AM ---------- Previous update was at 03:09 AM ----------

Im using this:

Code:
 
for var in `ll -tr | awk '{print $9}'`
do
echo "`ll -tr $var|cut -c 45-` \c ";cat $var
done

but it does not work properly... it prints extra stuff!
# 20  
Old 10-21-2011
You had it all in my previous post,what do you want? Using YOUR filenames?

OK again:
Code:
ant:/home/vbe/z01 $ ll
total 66
drwxrwxr-x   2 vbe        bin           1024 Oct 21 14:38 .
-rw-rw-r--   1 vbe        bin              0 Oct 21 14:32 . -r
drwxr-xr-x  55 vbe        bin          29696 Oct 20 18:08 ..
-rw-rw-r--   1 vbe        bin              6 Oct 21 14:37 text1.txt
-rw-rw-r--   1 vbe        bin              5 Oct 21 14:38 text2.txt
-rw-rw-r--   1 vbe        bin              9 Oct 21 14:38 text3.txt
ant:/home/vbe/z01 $ 
###---- Your ll -tr ...---###
ant:/home/vbe/z01 $ ll -tr  | awk '{print $6, $7, $8, $9}'| while read tet tit>

Oct 20 18:08 ..
Oct 21 14:32 .
Oct 21 14:37 text1.txt
Oct 21 14:38 text2.txt
Oct 21 14:38 text3.txt
Oct 21 14:38 .
### See the difference? ###
ant:/home/vbe/z01 $ ll -tr * | awk '{print $6, $7, $8, $9}'| while read tet ti>
text1.txt
hello
text2.txt
yes?
text3.txt
good-bye

You got it this time?
# 21  
Old 10-21-2011
sorry line on terminal not complete when hardcopy
I changed the line size...
Code:
ll -tr * | awk '{print $6, $7, $8, $9}'| while read tet titi tata toto; do echo $toto&&cat $toto; done

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to add prefix using sed or awk from cat the file

I need the use sed or AWK using cat the file Node1 TDEV RW 1035788 TDEV RW 1035788 Server1 TDEV RW 69053 Server2 TDEV RW 69053 TDEV RW 103579 Server3 TDEV RW 69053 server4 RDF1+TDEV RW 69053 RDF1+TDEV RW 517894 RDF1+TDEV RW 621473 server6 TDEV RW 34526 TDEV RW 34526 (22 Replies)
Discussion started by: ranjancom2000
22 Replies

2. Shell Programming and Scripting

Spacing off when files combined using awk or cat

I have 133 .txt files in a directory that I am combining into 1 file. The problem is when I use awk or cat to combine the files I get out put like this: output 85 138662360 KCNT1 86 138662962 KCNT1 82 138657053 KCNT1 83 138657635 KCNT1 95 138646881 KCNT1... (12 Replies)
Discussion started by: cmccabe
12 Replies

3. UNIX for Dummies Questions & Answers

How to pass cat file in awk statement?

Hi, I am working on kernel parameters, want to check values under /proc/sys/kernel below I tried for kernel.sem SEMMNS: 4096 cat /proc/sys/kernel/sem | awk '{print $2}' awk '{ if ($2 < 33000) print }' /proc/sys/kernel/sem |awk '{print $2}' 32000 The above... (7 Replies)
Discussion started by: stew
7 Replies

4. Shell Programming and Scripting

Using cat and awk.......

Im trying to use cat and awk to calculate the total space, then display it using the print command. But something in my script is not correct? cat | awk '{print$1}' | sort -n | grep -v used | awk '{sum += $1} END { p rint sum;}' ??? Any help would be greatly appreciated!! (10 Replies)
Discussion started by: bigben1220
10 Replies

5. Shell Programming and Scripting

Understanding Awk and Cat

Hi Guys, I was recently come across some code to hopefully learn a little bit about putting Shell commands into PHP application to run on a Linux server. However, I don't understand the command AT ALL... and was wondering if anyone can interpret it: cat userIDs.dat | awk '{s=s+1; if... (1 Reply)
Discussion started by: jordRiot
1 Replies

6. UNIX for Dummies Questions & Answers

tr, sed, awk, cat or scripting

I need to change all Newline caracters (\12) to Fieldseparator(\34). tr -A '\12' '\34' <file1> file2 Replace all delete (\177) with Newline (\12) tr -A '\177' '\12' <file2> file3 Put the name of the file first in all rows. awk '{printf "%s\34%s\n", FILENAME,$0} file3 > file4 So far no... (6 Replies)
Discussion started by: MrKlint
6 Replies

7. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

8. Shell Programming and Scripting

cat & awk

Hi there, Can show some hit why i got this error? For eg i have a.txt in which consist of contents as below 1|781494-0015|IV\|I||C|RECHARGE|Success\|V\|\||2007-12-04 02:33:13.000| 2|762405-0405|IV\|I||C|RECHARGE|Success\|V\|\||2007-12-04 02:33:17.000| In fact , i want to perfrom to have... (2 Replies)
Discussion started by: rauphelhunter
2 Replies

9. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies
Login or Register to Ask a Question