[Solved] Size (Sort files using ...)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Size (Sort files using ...)
# 1  
Old 01-17-2014
[Solved] Size (Sort files using ...)

Code:
-rw-r--r-- 1 oracle oinstall   4 Jan 17 16:23 a
-rw-r--r-- 1 oracle oinstall 212 Jan 17 17:51 amar
-rw-r--r-- 1 oracle oinstall  32 Jan 17 17:30 b
-rw-r--r-- 1 oracle oinstall 246 Jan 17 15:40 h1.tar.gz

Hi,

I want combination of linux command to sort out the line which has 32k size.

Output should be like:
Code:
-rw-r--r-- 1 oracle oinstall  32 Jan 17 17:30 b

Note: If 32 is found in created time or altered time this should not get considered.

Aim is to sort the line which has size of 32K.

Help me out in this regard.

Thanks in advance

Last edited by Scott; 01-17-2014 at 08:31 AM.. Reason: Please use code tags; Really nothing to do with Red Hat, so thread moved
# 2  
Old 01-17-2014
Please post what have you tried?
# 3  
Old 01-17-2014
Code:
ls -l | cut -d ' ' -f5

---------- Post updated at 06:07 PM ---------- Previous update was at 06:05 PM ----------
Code:
ls -l | awk '{print $5}' | grep 32

Output for this is:

32

But I want entire long list of this size 32

Kindly help me out

Moderator's Comments:
Mod Comment please use code tags!

Last edited by vbe; 01-17-2014 at 08:43 AM..
# 4  
Old 01-17-2014
Sample

Code:
ls -lrt | awk '$5 == 32 { print }'

# 5  
Old 01-17-2014
Really thanks.

Really works fine

---------- Post updated at 06:37 PM ---------- Previous update was at 06:09 PM ----------

Hi. How to use two conditions such as AND or OR in this,.

For eg

1) I want to pick long list with size either 32 or 10
2) I want to pick long list with size either 32 and 10

Plz help me out as your solution is really good
# 6  
Old 01-17-2014
Please give it a try for yourself

sample

Code:
ls -lrt | awk '$5 == 32 || $5 == 10 { print }'

Code:
ls -lrt | awk '$5 == 32 && $5 == 10 { print }'

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to sort the files by size and based subdirectory un UNIX?

I have the below input data in a file and need to get the output as mentioned below. Need to sort the data by size(Asc/des)/by subdirectory Below is the input which is there in a file: 120 /root/path2/part-00000-d3700305-428d-4b13-8161-42051f4ac5ed-c000.json 532 ... (3 Replies)
Discussion started by: ajarramuk
3 Replies

2. Shell Programming and Scripting

[Solved] sort on numeric part of field

I have ran into a heavy case of PEBCAK*) and could need some advice on what i do wrong: OS is Linux (kernel 2.6.35), sort --version reports "8.5" from 2010, shell is ksh. Originally i had a file with with the following structure: hdisk1 yyy hdisk2 yyy hdisk3 yyy hdisk4 yyy hdisk5 yyy... (2 Replies)
Discussion started by: bakunin
2 Replies

3. Shell Programming and Scripting

[Solved] Help with Sort command (ksh)

hello everyone, I have file with de-limited values in random order shown below, where C1V0 represents column1 value1, C2V0 represents column2 value 2, and so on. Column0 is a constant value which i didn't represent in the sample input format. Column1 is a numeric column. Column2 is a... (0 Replies)
Discussion started by: angie1234
0 Replies

4. Shell Programming and Scripting

[SOLVED] Sort on multiple keys

Can you guys pls take a look at this. I need to sort this list of numbers as follows: 2nd col first, then 1st col, then 3rd col, all in reverse (highest to lowest). I'm doing this: sort -k 2,2nr -k 1,1nr -k 3,3gr but, as you see, the 3rd col does not get sorted properly. Any idea... (0 Replies)
Discussion started by: mamboknave
0 Replies

5. Shell Programming and Scripting

sort by size

Can some one help in sorting the attached file. I used cmd: sort -r jar1.txt -o sortedjar.txt , but it didnt work. Thanks for your help in Advance. (6 Replies)
Discussion started by: sawyer
6 Replies

6. Shell Programming and Scripting

[solved] merging two files and writing to another file- solved

i have two files as file1: 1 2 3 file2: a b c and the output should be: file3: 1~a 2~b 3~c (1 Reply)
Discussion started by: mlpathir
1 Replies

7. UNIX for Dummies Questions & Answers

sort by size in Mb and Kb

Hi I am using the command below to list the 10 biggest directories and files in my present directory du -hs * | sort +0 | tail -10 the output is 8K disk-space 16K rish 32K WINDOWS 48K tests 104K imgvdEwLa.jpg 168K 020204_aerosmith_1024768.jdk 3.2M Acdc -... (4 Replies)
Discussion started by: the.noob
4 Replies

8. Shell Programming and Scripting

sort files by date, delete oldest, if total size bigger than

hello people i need your help please i want to achieve the following with the simplest, most efficient shell-tools: i have a directory with a lot of files from users. the script should check which partition the dir is on if the partition with the directory is more than 90% full ... (2 Replies)
Discussion started by: scarfake
2 Replies

9. Shell Programming and Scripting

bash script working for small size files but not for big size files.

Hi, I have one file stat. Stat file contents are as follows: for example. H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000 Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies

10. UNIX for Dummies Questions & Answers

sort files by size

Is there a way to sort files by size using the ls command? thanks in advance (1 Reply)
Discussion started by: AMD
1 Replies
Login or Register to Ask a Question