merging two file in an ordered way


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting merging two file in an ordered way
# 1  
Old 09-22-2005
merging two file in an ordered way

actually, it seems somewhat confusing.. let me clearify it

i want a file having all the attributes produced by ls -lc command. i want to add one more thing i.e. time of last access to a file attribute. so how can i merge these two things in a single file in a columnar way.

i tried with these but didn't helped actually

ls -lu > file_with_last_access_time

awk -F" " '{print $8}' file_with_last_access_time > last_access_time
//just grab the last acces time attribute from file_with_last_access_time

ls -lc | sort -m last_access_time - > final_file
// lists all attributes of the directory (including last modified time) and merge it with last access time

well, it worked but the things were in the bottom, i want them in the last column...

plz help me

Last edited by raku05; 09-22-2005 at 08:24 AM.. Reason: to clearify
# 2  
Old 09-22-2005
I really don't understand exactly what you want but this may help:

find . -maxdepth 1 -printf "%A@ %AT %CT %P\n" | sort -k1,1n
# 3  
Old 09-22-2005
MySQL

To my understanding u wish to have listing of both time stamps in one listing.


To achieve this:

ls -lu | sort +8 >> /tmp/file1
ls -lc | sort +8 >> /tmp/file2
paste /tmp/file1 /tmp/file2 | awk '{print $1,$2,$3,$4,$5,$6,$7,$8,$9,$17}' | sed -e '1d'

I know it is not the best solution...but hope it helps Smilie

rishi
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

merging two file

Dear All, I have two file like this: file1: a1234 b1235 c4678 d7859 file2 : e4575 f7869 g7689 h9687 I want output like this: a1234 b1235 c4678 (2 Replies)
Discussion started by: attila
2 Replies

2. UNIX for Dummies Questions & Answers

make ls retrive ordered list of elements

Hello friends!! I have a question regarding the use of ls in unix. I have a folder with files: t1.txt t2.txt t3.txt t4.txt ... t10.txt When I make an ls I always get: t10.txt t1.txt t2.txt t3.txt .. t9.txt (2 Replies)
Discussion started by: SaktiPhoenix
2 Replies

3. What is on Your Mind?

I just ordered a Mini-Box with no fan!

I just ordered a Mini-Box M350 with a Mini-ITX Intel DM510MO motherboard. NO FAN! I've come to hate the wine of spinning mechanisms in PCs in my quiet home. This one is for surfing the web in my living room (instead of using this laptop), so it doesn't really need much power. If I do... (1 Reply)
Discussion started by: KenJackson
1 Replies

4. UNIX for Advanced & Expert Users

verify ordered records

I need to resolve next problem, I have a unix txt file, I need to verify that it is to ordered for a key , in this case CUSTOMER, I need to do it with awk , it is shows an example Incorrect Correct CUSTOMER PRODUCT CUSTOMER PRODUCT 1 |01 1 ... (7 Replies)
Discussion started by: bsobarzoa
7 Replies

5. Shell Programming and Scripting

Extracting a column from a file and merging with other file using awk

Hi All: I have following files: File 1: <header> text... text .. text .. text .. <\header> x y z ... File 2: <header> text... text .. text .. (4 Replies)
Discussion started by: mrn006
4 Replies

6. Shell Programming and Scripting

Merge 3 files in 1 file in an ordered way

Hi, I have a question that I cannot solve. if I have a file like this (lets say "x-values.dat"): x1 x2 x3 another file like this (lets say "y-values.dat"): y1 y2 y3 y4 and another file like this (lets say "p-values.dat"): p1 p2 p3 ... p12 How can I get this output? x1 y1 p1 x1 y2... (16 Replies)
Discussion started by: lego
16 Replies

7. UNIX for Dummies Questions & Answers

Print folder size ordered by pattern value of specific file type :-) ! challenge !

Hello dear unix command line friends ! I'm looking for a simple combinaison of ls & awk (maybe grep) to print: list of folders of a directory |_ ordered by size like what I have with $ du -sk ./* | sort -rn printing that result: 8651520 ./New Virtual Machine_1 8389120 ./Redhat ... (1 Reply)
Discussion started by: holister
1 Replies

8. UNIX for Dummies Questions & Answers

merging 2 file

I have 2 files file1.txt a 123 aqsw c 234 sfdr fil2.txt b 345 hgy d 4653 jgut I want to merger in such a manner the the output file should be outfile.txt a 123 aqsw b 345 hgy c 234 sfdr d 4653 jgut Do we have any command to achive this? (8 Replies)
Discussion started by: siba.s.nayak
8 Replies

9. Shell Programming and Scripting

Script to unorder an ordered list

Wondering if someone could help me with this in any scripting/programming language. I have a list of ordered IP addresses and I want to unorder them. So for example, if I had a file like this: 111.111.111.110 111.111.111.111 111.111.111.112 111.111.111.113 111.111.111.114 I would want to... (4 Replies)
Discussion started by: kerpm
4 Replies
Login or Register to Ask a Question