![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| searching for content of files | Aretai | UNIX for Dummies Questions & Answers | 19 | 03-09-2007 06:44 AM |
| grep/cat/more -- search in a txt file and display content from a specific "keyword" | I-1 | UNIX for Dummies Questions & Answers | 4 | 02-21-2007 04:57 AM |
| Cleaning the content of log files | jyotipg | Shell Programming and Scripting | 1 | 11-15-2006 02:19 AM |
| content need changes- many files | swchee | Shell Programming and Scripting | 3 | 10-05-2006 12:29 PM |
| Compare the content of 2 files | odogbolu98 | Shell Programming and Scripting | 3 | 09-10-2002 11:44 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
hello,
i have a question and i'll be appreciated if you can help me with this. i have i folder let's say "users" in this folder there are files (file1, file2, file2, etc) and in each file there is a number (lets say 4 in file1) i want to display some thing like bellow file1 4 file2 3 file3 2 file4 1 i want also the files names to be sorted alphapitical order.. Is this possible ! (using shell script)Thanks a lot. |
|
||||
|
wow
Thanks a lot pmm, this was very helpfull... i got the bellow myfiles/file1 4 myfiles/file2 3 myfiles/file3 2 ... can i display this result with any kind of format! like file name value file1 4 file2 3 file3 2 and so on Regards |
|
||||
|
Ok - try this
nawk ' { print FILENAME "/" $1 }' `ls files/file*` | sort | nawk -F/ ' BEGIN { printf "%10s\t%10s\n","Filename","Value" } { printf "%10s\t%10s\n",$(NF-1),$NF } ' First nawk does as previous but makes output: myfiles/file1/1 etc. Second nawk does formatting with prints, printing header in BEGIN section, then format printing second last and last fields. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|