Sponsored Content
Top Forums UNIX for Advanced & Expert Users Problem piping find output to awk, 1st line filename is truncated, other lines are fine. Post 302846691 by gencon on Sunday 25th of August 2013 12:44:26 PM
Old 08-25-2013
Thanks Scrutinizer, that works.

I thought that anything before the awk {} was before the first line. Oops, so obvious once you know. Smilie

To anyone who's interested, this also works:
Code:
$ find . -type f -printf '%s**%p\n' | sort -nr | awk 'BEGIN {FS="**"} {printf("%d \t%s\n", $1, $2)}'
45     ./Test Dir 1/Test File 1
30     ./Test Dir 2/Test File 2
23     ./Test Dir 3/Test File 3
18     ./Test Dir 4/Test File 4

as does...

$ find . -type f -printf '%s**%p\n' | sort -nr | awk 'BEGIN {FS="[*][*]"} {printf("%d \t%s\n", $1, $2)}'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ps output truncated

Hi! I have some shell scripts receiving in input lots of parameters and I need to select the ones having a particular value in one parameter. A typical shell command line is: PROMPT > shell_name.ksh -avalue_a -bvalue_b -cvalue_c -dvalue_d ... I used a combinaton of ps and grep commands... (1 Reply)
Discussion started by: pciatto
1 Replies

2. UNIX for Dummies Questions & Answers

piping the output of find command to grep

Hi, I did not understand why the following did not work out as I expected: find . -name "pqp.txt" | grep -v "Permission" I thought I would be able to catch whichever paths containing my pqp.txt file without receiving the display of messages such as "find: cannot access... Permisson... (1 Reply)
Discussion started by: 435 Gavea
1 Replies

3. UNIX for Dummies Questions & Answers

Using awk to get a line number to delete, piping through sed

Alright, I'm sure there's a more efficient way to do this... I'm not an expert by any means. What I'm trying to do is search a file for lines that match the two input words (first name, last name) in order to remove that line. The removal part is what I'm struggling with. Here is my code: echo... (4 Replies)
Discussion started by: lazypeterson
4 Replies

4. Shell Programming and Scripting

awk find a string, print the line 2 lines below it

I am parsing a nagios config, searching for a string, and then printing the line 2 lines later (the "members" string). Here's the data: define hostgroup{ hostgroup_name chat-dev alias chat-dev members thisisahostname } define hostgroup{ ... (1 Reply)
Discussion started by: mglenney
1 Replies

5. Shell Programming and Scripting

Find in first column and replace the line with Awk, and output new file

Find in first column and replace the line with Awk, and output new file File1.txt"2011-11-02","Georgia","Atlanta","x","","" "2011-11-03","California","Los Angeles","x","","" "2011-11-04","Georgia","Atlanta","x","x","x" "2011-11-05","Georgia","Atlanta","x","x","" ... (4 Replies)
Discussion started by: charles33
4 Replies

6. Solaris

ps output truncated

Hi, I have Solaris-10 server. /usr/ucb/ps auxww is showing full path if I am running it from root. But if I run it from non-root user, its output is truncated. I don't want to use any other alternate command. Please suggest, what can be its solution. Terminal is set to term. (21 Replies)
Discussion started by: solaris_1977
21 Replies

7. Shell Programming and Scripting

awk problem two lines in the same line

Hi guy, I have an output command like this: Policy Name: NBU.POL.ORA.PROD Policy Type: Oracle Active: yes HW/OS/Client: Linux RedHat2.6 node1 Iclude: /usr/openv/netbackup/scripts/backup_ora1.bash I would like to parse the... (1 Reply)
Discussion started by: luca72m
1 Replies

8. Shell Programming and Scripting

(n)awk: print regex search output lines in one line

Hello. I have been looking high and low for the solution for this. I seems there should be a simple answer, but alas. I have a big xml file, and I need to extract certain information from specific items. The information I need can be found between a specific set of tags. let's call them... (2 Replies)
Discussion started by: Tobias-Reiper
2 Replies

9. Shell Programming and Scripting

Script using awk to find and replace a line, how to ignore comment lines

Hello, I have some code that works more or less. This is called by a make file to adjust some hard-coded definitions in the src code. The script generated some values by looking at some of the src files and then writes those values to specific locations in other files. The awk code is used to... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

10. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
MouseX::Types::Path::Class(3pm) 			User Contributed Perl Documentation			   MouseX::Types::Path::Class(3pm)

NAME
MouseX::Types::Path::Class - A Path::Class type library for Mouse SYNOPSIS
CLASS TYPES package MyApp; use Mouse; use MouseX::Types::Path::Class; has 'dir' => ( is => 'ro', isa => 'Path::Class::Dir', required => 1, coerce => 1, ); has 'file' => ( is => 'ro', isa => 'Path::Class::File', required => 1, coerce => 1, ); CUSTOM TYPES package MyApp; use Mouse; use MouseX::Types::Path::Class qw(Dir File); has 'dir' => ( is => 'ro', isa => Dir, required => 1, coerce => 1, ); has 'file' => ( is => 'ro', isa => File, required => 1, coerce => 1, ); DESCRIPTION
MouseX::Types::Path::Class creates common Mouse types, coercions and option specifications useful for dealing with Path::Class objects as Mouse attributes. Coercions (see Mouse::Util::TypeConstraints) are made from both "Str" and "ArrayRef" to both Path::Class::Dir and Path::Class::File objects. If you have MouseX::Getopt installed, the Getopt option type ("=s") will be added for both Path::Class::Dir and Path::Class::File. TYPES
Dir A Path::Class::Dir class type. Coerces from "Str" and "ArrayRef" via "new" in Path::Class::Dir. File A Path::Class::File class type. Coerces from "Str" and "ArrayRef" via "new" in Path::Class::File. AUTHOR
NAKAGAWA Masaki <masaki@cpan.org> THANKS TO
"AUTHOR" in MooseX::Types::Path::Class LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Mouse, MouseX::Types, Path::Class, MooseX::Types::Path::Class perl v5.14.2 2012-04-01 MouseX::Types::Path::Class(3pm)
All times are GMT -4. The time now is 10:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy