UNIX command question


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers UNIX command question
# 1  
Old 01-08-2015
UNIX command question

Hi Guys,

I am new on the scripting world and would like ask for help if you can.

Here are my questions below:-
  1. What Unix command(s) would you put in a shell script to read an ASCII comma-delimited input file and validate that field 5 only contains numeric characters?
  2. What Unix command(s) would you use from the command line to find all files underneath a given path that have duplicate lines of data?

If you could provide a simple scenario that would be a big help.

Thanks you in advanced.

Last edited by rbatte1; 01-12-2015 at 08:18 AM.. Reason: Added LIST=1 tags and spelling
# 2  
Old 01-08-2015
Is this a homework assignment? If so, please refile it in the Homework and Coursework Questions forum with the completed template required for that forum.
# 3  
Old 01-08-2015
It's work related and for some reason this question was approach to me by my co workers here in the office. To tell you honestly I don't really know the answer yet. I do some research like using awk, uniq, etc.. but I am not sure how to put that different commands in one liner were we could get the desire answer. Hopefully you could help on it Smilie.
# 4  
Old 01-08-2015
For the 1st problem, you can try:
Code:
awk -F, ' {print $0, ($5 == "" || match($5, /[^[:digit:]]/)) ? "non-numeric" : "numeric"}' input_file

If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk.

For the 2nd problem, you need to much more clearly define the problem. Are you looking for files that contain a duplicate of a given line? Are you looking for files that contain two identical lines? Are you looking for files that contain any line that is also present in any other file under the same directory?
# 5  
Old 01-09-2015
Yes I am looking for all the thing you have said about the lines. Actually all of then that you have said.

Last edited by mahiwaga; 01-09-2015 at 01:26 AM..
# 6  
Old 01-09-2015
Show us sample input. Show us sample output that you want from that input. Clearly describe why that output should be produced from the sample input you show us. Look at the man pages for grep and awk. Show us what code you have used to try to solve these problems. (Use CODE tags when you show us all of the sample input, output, and code.)

Tell us what OS and shell you're using.

If you aren't willing to show us that you're willing to put some effort into this yourself, there isn't much incentive for us to do your work for you. We're happy to help you learn how to use the tools available on UNIX and Linux systems to perform the tasks you want to get done. We are not here to act as your unpaid programming staff.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Unix ls command question

There was a question that I have been asked, I won't lie it is from homework, regrading the ls, list, command and I am hopelessly lost and just can't seem to figure it out. Here is question: Summarized Question There is something about the naming of the files in a directory that cause ls,... (4 Replies)
Discussion started by: TheRaiderNation
4 Replies

2. UNIX for Dummies Questions & Answers

New to Unix command line and have a question about the "sort" command

I am going through the Unix Made Easy second edition book by John Muster. So far it's been very informative and I can tell it may be a bit out of date. In one of the exercises it talks about the "sort" command and using it to sort column's of data etc. The "sort" command has changed a bit and... (1 Reply)
Discussion started by: budfoxcat
1 Replies

3. UNIX for Dummies Questions & Answers

Unix command line question

I'm new to Unix and I'm looking for some assistance. We have 20 different accounts we must login to every day. Logging in has become quite the chore and most nights, we have to log out. I'm looking for a way to simply copy and paste the commands into each window to make things easier. I have been... (2 Replies)
Discussion started by: Judo_Bear
2 Replies

4. Shell Programming and Scripting

question about wc command in Unix

Hi all I want to give a command which outputs the number of files have name ending in .pdf(output is just number). Can somebody help me (3 Replies)
Discussion started by: thungmail
3 Replies

5. HP-UX

Question about UNIX ioscan command

Hello there. I have a question regarding the ioscan commnad. When you execute the line ioscan -fnC processor it outputs a list of all processors in the machine. Does this list displays only physical CPUs or does it displays each core? For example, if i have a server with 1 Dual Core... (10 Replies)
Discussion started by: Spilson
10 Replies

6. UNIX for Dummies Questions & Answers

Unix command question

I recently went in for a job interview and the guy asked me what I knew about Unix. I told him not much since I haven't worked with it in a few years. He then asked me the following question: What Unix or Linux shell command will tell you the names of all files in the current directory, along... (2 Replies)
Discussion started by: BMWBigD
2 Replies

7. UNIX for Dummies Questions & Answers

Unix History Question: Why are filenames/dirnames case sentsitive in Unix?

I tried looking for the answer online and came up with only a few semi-answers as to why file and directory names are case sensitive in Unix. Right off the bat, I'll say this doesn't bother me. But I run into tons of Windows and OpenVMS admins in my day job who go batty when they have to deal... (3 Replies)
Discussion started by: deckard
3 Replies

8. UNIX for Dummies Questions & Answers

Question about DOS versus Unix Command?

Okay here is a DOS comparison. When I search for a file in DOS and I was not sure what directory it was in then I would put dir /s/o/p filename the s would tell it to look in every directory including subs, the o would sort it alphabetically and the p would limit the display to one page at a... (1 Reply)
Discussion started by: wmosley2
1 Replies

9. Shell Programming and Scripting

Question about a unix command...

hi all, got a question about grep, ive written a script (Bourne) and i'm using grep -i to search for a file and return the records that i'm looking for. This all works fine, but, i was wondering how i can get an error message if that word isn't in the file. E.G. the user enters: tree and if... (2 Replies)
Discussion started by: wazzag
2 Replies

10. IP Networking

unix to unix serial connection question

hi there i'm a new bie just got few simple questions to ask. I got expert in windows configuration but totally new to unix environment . I want to make sure a com port (com1) is working, so I connect a 9-pin cable (CB9) for both PC using Unix environment (unix to unix). The question are (1)... (1 Reply)
Discussion started by: typsam
1 Replies
Login or Register to Ask a Question