Unix/Linux Scripts questions

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Unix/Linux Scripts questions
# 1  
Old 10-01-2007
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  
Old 10-01-2007
Homework? (rule 6)
# 3  
Old 10-02-2007

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  
Old 10-02-2007
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  
Old 10-02-2007
what does it accomplish
# 6  
Old 10-03-2007
Originally Posted by am2007
what does it accomplish
  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  
Old 10-03-2007
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Scripts imported from UNIX to Linux are not working

Hi, Recently we migrated our app from Unix to Linux platform. All our shell scripts which use to work in Unix platform are not working in Linux now. below is such sample script. I tried removing trailing spaces, but no luck. dear experts kindly help.. #############BEGIN############### split... (7 Replies)
Discussion started by: laxman_bly
7 Replies

2. UNIX for Dummies Questions & Answers

Alternate of UNIX scripts in Linux

Hai All, Greetings.... I am doing a migration from Solaris to Linux .There are few scripts (logadm, nfsfind, gsscred_clean, kprop_script) for which I need a alternate in Linux. If somebody can help. Thanks in advance (1 Reply)
Discussion started by: Dilipkumarkm
1 Replies

3. UNIX for Dummies Questions & Answers

Unix vs linux in the job place and other questions

hello all, im new to this site...and look forward to corresponding with you all. i am a microsoft kid (sad) currently i work on small networks and repair computers for home and business. i want to better my skill set...but dont want to carry on down the MS route. Basically i want to... (12 Replies)
Discussion started by: j0n1n
12 Replies

4. UNIX for Dummies Questions & Answers

Unix and Linux questions

Sorry for the dumb question......I got my B.S. in computer science Amazing how I don't these answers).....I wrote mostly in the language C in my college career. I wrote all my programs using a windows application for writing C.....and then after testing it, I would upload it to a UNIX system and... (1 Reply)
Discussion started by: Bruuuuce78
1 Replies

5. UNIX for Dummies Questions & Answers

Few questions on unix/linux

Hi , please give few answers for this questions:confused::confused: ...thanks in advance What shell do you use when you log in to a UNIX/Linux host? What command will show you the shell you're using? Describe 5 things you can do in Linux/UNIX. (1 Reply)
Discussion started by: hecker007
1 Replies

6. Windows & DOS: Issues & Discussions

UNIX/Linux for Windows? and a few other questions...

1) I want UNIX but I don't want to partition my hard drive. I have heard of programs that allow you to start UNIX from Windows but I don't know which one is good. Something like WinLinux (not too sure???) Anyone know which programs I'm talking about? 2) Is Linux UNIX? 3) How do you pronounce... (9 Replies)
Discussion started by: CornNuts
9 Replies

7. What is on Your Mind?

Questions about Unix/Linux

Hello all. Im a young lad with very limited experience with computers, even though I have been playing with them the past 5 years. I have the experience of the random World of Warcraft player that plays games all day. I have a huge interest in learning everything about computers and I was... (5 Replies)
Discussion started by: Vallzi
5 Replies

8. UNIX for Dummies Questions & Answers

pulling scripts from unix to linux

:confused: I am working on transferring "good" running code scripts from unix to linux (suse). Some errors show in linux that are not present in unix. Specifically, the error code is: codename : no closing quote This is referring to the last line of the code + one line. I have used temporary... (3 Replies)
Discussion started by: pjconfig
3 Replies

9. UNIX for Dummies Questions & Answers

Absolute n00b questions about Unix / Linux

Hi All, I have absolutely no experince with either one, and would LOVE to start from somewhere! So please guide me to some web sites (beside these great forums of course!) that I can obtain n00b information. (Books, links, resources, etc.) What software OS? should I begin with? I have heard... (2 Replies)
Discussion started by: CodeHunter
2 Replies
Login or Register to Ask a Question