Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Grep Script

Shell Programming and Scripting


Tags
scripting

Reply    
 
Thread Tools Search this Thread Display Modes
    #15  
Old Unix and Linux 1 Day Ago
Con592 Con592 is offline
Registered User
 
Join Date: Sep 2017
Last Activity: 20 September 2017, 6:05 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks I am looking more into the awk command

---------- Post updated at 04:02 PM ---------- Previous update was at 02:55 PM ----------


Code:
 
 awk -v OFS="\t" '
BEGIN   {print "Owner name   file size    time of last Modification   directory"
        }
        {print $3, $5, $6 " " $7 " " $8, $9
        }
'

Is it possible to add more space between the results
Code:
{print $3, $5, $6 " " $7 " " $8, $9
        }


Last edited by Con592; 1 Day Ago at 10:20 AM..
Sponsored Links
    #16  
Old Unix and Linux 1 Day Ago
drl's Unix or Linux Image
drl drl is offline Forum Advisor  
Registered Voter
 
Join Date: Apr 2007
Last Activity: 20 September 2017, 1:00 PM EDT
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,166
Thanks: 219
Thanked 400 Times in 345 Posts
Hi.

Assuming that your file is TSV (Tab-Separated-Values), looking like this on file z6:

Code:
$ cat -A z6
Owner name^Ifile size^Itime of last Modification^Idirectory$
root^I2048^ISep 18 11:11^Iafile.exe$

Then you could use utility align, like so, output separated by TABs:

Code:
$ align -st z6
Owner name	file size	time of last Modification	directory
root		2048		Sep 18 11:11			afile.exe

For more control over spacing, use a gutter change with blanks to separate:

Code:
$ align -st -js -g3 z6
Owner name   file size	 time of last Modification   directory
root	     2048	 Sep 18 11:11		     afile.exe

Here are some details for align:

Code:
align   Align columns of text. (what)
Path    : ~/p/stm/common/scripts/align
Version : 1.7.0
Length  : 270 lines
Type    : Perl script, ASCII text executable
Shebang : #!/usr/bin/perl
Help    : probably available with --help
Home    : http://kinzler.com/me/align/ (doc)
Modules : (for perl codes)
 Getopt::Std    1.10

Best wishes ... cheers, drl
Sponsored Links
    #17  
Old Unix and Linux 21 Hours Ago
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 20 September 2017, 2:21 PM EDT
Location: Aachen, Germany
Posts: 11,352
Thanks: 297
Thanked 3,521 Times in 3,240 Posts
Quote:
Originally Posted by Con592 View Post
.
.
.
Is it possible to add more space between the results
Code:
{print $3, $5, $6 " " $7 " " $8, $9
        }

If your awk allows for it, try -v OFS="\t\t" so it separates fields with two <TAB>s.
    #18  
Old Unix and Linux 9 Hours Ago
Con592 Con592 is offline
Registered User
 
Join Date: Sep 2017
Last Activity: 20 September 2017, 6:05 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Instead of
Code:
\t

is there something for a space?
Sponsored Links
    #19  
Old Unix and Linux 8 Hours Ago
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 20 September 2017, 2:21 PM EDT
Location: Aachen, Germany
Posts: 11,352
Thanks: 297
Thanked 3,521 Times in 3,240 Posts
Try

Code:
.
.
.
        {printf "%-13s%-13s%-28s%-20s\n", $3, $5, $6 " " $7 " " $8, $9
        }
'
Owner name   file size    time of last Modification   directory
root         2048         Sep 18 11:11                afile.exe

Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with script - GREP mirkocosta Shell Programming and Scripting 7 08-03-2015 07:47 AM
script use min resource ( grep grep) pooyair Shell Programming and Scripting 8 03-07-2011 10:43 AM
How to grep sql error in shell script and exit the script? allinshell99 Shell Programming and Scripting 2 05-27-2010 09:06 PM
trying to grep the first few lines of a continuos script, and exit the script anyidea k00061804 UNIX for Dummies Questions & Answers 5 07-22-2009 12:15 PM
grep script drchris UNIX for Dummies Questions & Answers 4 05-17-2007 09:32 AM



All times are GMT -4. The time now is 02:23 PM.