Parsing columns in bash
Hi,
as a result of a find command, i have 852065 72: /bin/gunzip 852065 72: /bin/gzip 852065 72: /bin/zcat (the first column is inode number and the second is size if you're curious) I want to be able to format it in a way such that: 852065 72: /bin/gunzip /bin/gzip /bin/zcat I know I can get the bottom half using awk- but I can't figure out how to extract the first set of numbers and get them to appear only once any help? Thanks! |
Quote:
Also, do you really think you can list multiple files, all with the same inode number? That's not how inode numbers work. Pretend that the information matters to the solution (because it does). Explain the problem properly -- otherwise there is no chance to solve it. |
Quote:
The first numbers change depending on the directory: for example, if i execute find /bin ! -type d -links +2 -ls 2>/dev/null | sort -g | awk '{ print $1, $2":", $11 }' then the result above appears My issue is mainly with formatting, i'm just new to using bash |
Quote:
|
Quote:
does the snippet of awk do what you want? save to script.awk, rund like find .... | awk -f script.awk Code:
BEGIN{ Cheers, Tink |
Quote:
|
Quote:
say you have a long listing: ls -l -rw-r--r-- 2 seb357 faculty 1215 Mar 25 2009 banana -rw-r--r-- 1 seb357 faculty 443 Sep 27 18:06 chkopts.bash -rw------- 1 seb357 faculty 358 Mar 31 2008 dead.letter drwxr-sr-x 3 seb357 faculty 4096 Apr 13 16:28 gasudoku I want to be able to capture a single cell from that table, so i could do something like making a variable named user = seb357 |
Quote:
If "as general as possible" is on a version of *n*x that produces ls -l output in the same format as on your current version and only operates on files with names that ls can display then Code:
#!/bin/bash |
For example 1:
The simplest way I can think of to get the output above from the input above is: Code:
find ... | awk '{ if (NR == 1) printf("%s %s\n%s\n", $1, $2, $3); else print $3 }' For example 2: Code:
bash-3.1$ var=$(ls -l | cut -d' ' -f4 | head -n1) |
haha, as generic as possible for my two systems :)
Thank you a lot catkin, that's exactly what i needed |
All times are GMT -5. The time now is 05:47 AM. |