New To Unix- Need Help With Bash Commands for Printing


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users New To Unix- Need Help With Bash Commands for Printing
# 1  
Old 10-07-2012
New To Unix- Need Help With Bash Commands for Printing

Urgent Help - I have a problem, I need to know how to print a count of files from a specific date that passed and that failed. Additionally, print the name of the files located on the date, print a list of all dates during which a file with a name like 'test' was processed, and then determine whether the same file was processed on multiple days and what the results were on each date? This is all on a Tab Delimited File. Can someone help pls? I need answers in a a few hours at the latest. Thanks!
# 2  
Old 10-07-2012
Can you post some data from the TAB delimited file that you are reading that contains all this information?
# 3  
Old 10-07-2012
Tab Information

File Name
Date
Pass/Fail
wr_file_load_1
2012-07-03
P
wr_test_load_2
2012-08-01
F
wr_file_load_3
2012-09-13
P
wr_file_load_4
2012-09-18
P
...
...
...
# 4  
Old 10-07-2012
The example below is just one way you can quickly get the info/counts you want:
Code:
$ cat t
FileName        Date    Pass/Fail
wr_file_load_1  2012-07-03      P
wr_test_load_2  2012-08-01      F
wr_file_load_3  2012-09-13      P
wr_file_load_4  2012-09-18      P
wr_file_load_1  2012-07-05      P


# print a count of files for a specific date that passed and that failed
perl -lnwe 'BEGIN{$p=0; $f=0}; if (/.*\t2012-09-18\tP/) { $p++ } elsif (/.*\t2012-09-18\tF/) { $f++ }; END { print "Counts for 2012-09-18= P: $p  F: $f" }' t

# print the name of the files for a specific date
perl -lne 'print $1 if /(.*)\t2012-09-13\t/' t

# print a list of all dates for which a specific file was processed
perl -lne 'print $1 if /^wr_file_load_1\t(.{10,})\tP/' t

# print file names processed on multiple dates with pass/fail code
perl -lane '%fh;%fc;$fn=$F[0];$pf=$F[2]; $fc{$fn}=$fc{$fn}+1; $fh{$fn} = $pf; END {foreach $fn ( keys %fc ) { print "$fn  $fh{$fn}\n" if $fc{$fn}>1} }' t

# 5  
Old 10-07-2012
Thanks for the information! Can you Pipe with Grep on this too? I was wondering using print commands with grep for the specific information.
# 6  
Old 10-08-2012
You don't need print to print to shell. Any shell command that prints to standard output can print to the screen.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run several bash commands put in bash command line?

How to run several bash commands put in bash command line without needing and requiring a script file. Because I'm actually a windows guy and new here so for illustration is sort of : $ bash "echo ${PATH} & echo have a nice day!" will do output, for example:... (4 Replies)
Discussion started by: abdulbadii
4 Replies

2. Shell Programming and Scripting

Creating Printing Program in bash

HI I am trying to create a bash script to print whatever i type in It has to have these below to define the size of the label and what size to print the text N q609 A100,10,0,5,2,2,N," " P1 It has to be sent to below > /dev/usblp0 So what it has to be is Written... (12 Replies)
Discussion started by: bganse
12 Replies

3. UNIX for Dummies Questions & Answers

Sco Unix printing : jobs hangs in queue - printing via lp versus hpnpf

Hi, We have a Unix 3.2v5.0.5. I installed a printer via scoadmin, HP network printer manager with network peripheral name (hostname and ipadres are in /etc/hosts). This is the configuration file : Code: root@sco1 # cat configurationBanner: on:AlwaysContent types: simpleDevice:... (0 Replies)
Discussion started by: haezeban
0 Replies

4. Shell Programming and Scripting

Printing the line number in bash script

Hi, I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened. Thanks, (6 Replies)
Discussion started by: suryaemlinux
6 Replies

5. Shell Programming and Scripting

Printing special character in bash

I am using this character as a delimiter 'þ' Currently, I set it straight: DELIMITER='þ' However, while copying the file, this character often gets mangled. Is there a bash way (perhaps using tr or printf) of generating this character. It corresponds to "chr(0xfe)" if using perl. (I've... (6 Replies)
Discussion started by: sentinel
6 Replies

6. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

7. Shell Programming and Scripting

arrays not printing properly in bash

hi guys, i wrote this script and it takes some fields from a file and puts it into three different arrays. The first array works just fine but when I try to use the second array (ARRAY1) all i get is a blank value on the screen.. this works fine..i get ARRAY value on the screen just fine ... (1 Reply)
Discussion started by: npatwardhan
1 Replies

8. SCO

SCO Printing commands! Help PLEASE!

Hello All, I am upgrading a server from SCO to LINUX (CENTOS) and have about 50 odd printers which i have transferred. The only problem is, that they have hard coded printer commands which my new version of CUPS does not understand. For example: "-o nb -tl60" Once I know the... (1 Reply)
Discussion started by: stuaz
1 Replies

9. UNIX for Dummies Questions & Answers

Why do basic unix commands not work in BASH

Why do basic unix commands such as "ls" not work in "BASH" mode?? I am frustrated!! (10 Replies)
Discussion started by: PixelLover
10 Replies

10. UNIX for Advanced & Expert Users

Printing Problems in unix ... ( Bar-cdoe - Ip Printing)

Hi guys ... i need ur help with some printing problem in unix ... first prob. : i wanna print from my NCR unix to an Win NT , Ip based printing server ( HP JetDirect ) . My issue , is it possible to print directly to an Ip address from unix ? How do i make it work to get any results ?... (3 Replies)
Discussion started by: QuickSilver
3 Replies
Login or Register to Ask a Question