The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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
UNIX/Linux for Windows? and a few other questions... CornNuts Windows & DOS: Issues & Discussions 9 05-06-2009 06:36 AM
Questions about Unix/Linux Vallzi What's on Your Mind? 5 01-22-2007 02:09 PM
pulling scripts from unix to linux pjconfig UNIX for Dummies Questions & Answers 3 12-21-2005 06:10 PM
Absolute n00b questions about Unix / Linux CodeHunter UNIX for Dummies Questions & Answers 2 02-24-2005 09:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-01-2007
am2007 am2007 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 4
Unix/Linux Scripts questions

Hi All,

You have a very large file, named 'ColCheckMe', tab-delimited, that you are asked to process. You are told that each line in 'ColCheckMe' has 7 columns, and that the values in the 5th column are integers. Using shell functions (and standard LINUX/UNIX filters), indicate how you would verify that these conditions were satisfied in 'ColCheckMe'

In the same file, you are told that each value in column 1 is unique. How would you verify that?


Write a shell function that counts the number of occurrences of the word “SpecStr” in the file 'ColCheckMe'.

Please advice.

Thanks much.
  #2 (permalink)  
Old 10-01-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Homework? (rule 6)
  #3 (permalink)  
Old 10-02-2007
am2007 am2007 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 4
Hello,

This is not homework or school work. I'm a seasoned C++ developer on windows. My current project is both, windows and unix based. As part of my expanding job duties, I'm getting my feet wet in the unix world as well.

My problem is that I have a very large file called ColCheckMe which is tab-delimited, that I have to process. Each line in ColCheckMe has 7 columns, and the values in the 5th column are integers. Using shell functions (and standard LINUX/UNIX filters), I have to verify that these conditions are satisfied in ColCheckMe. In the same file, each value in column 1 is unique. How do I verify that? I have to write a shell function that counts the number of occurrences of the word “SpecStr” in the file ColCheckMe.

Thanks for any help.
  #4 (permalink)  
Old 10-02-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
nawk 'NF != 7 {printf("[%d] has invalid [%d] number of fields\n", FNR, NF)} $5 !~ /^[0-9]+$/ {printf("[%d] 5th field is invalid [%s]\n", FNR, $5)}' ColCheckMe

The rest is left as an excersize....
  #5 (permalink)  
Old 10-02-2007
am2007 am2007 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 4
what does it accomplish
  #6 (permalink)  
Old 10-03-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
Quote:
Originally Posted by am2007 View Post
what does it accomplish
it:
  1. checks for the valid number of fields
  2. checks for the 5-th field being integer field
Being 'seasoned C++' developer I'm sure you could've at least guessed OR at most tried it and saw the results....
  #7 (permalink)  
Old 10-03-2007
am2007 am2007 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 4
Well, first off, it's a shame if you write code (that too, all in one executable line) that only you can understand....no need for the brickbats though. If you don't like to help without throwing insults, then don't help at all.
Sponsored Links
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:38 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0