Sponsored Content
Full Discussion: Noob on Unix.
Top Forums UNIX for Dummies Questions & Answers Noob on Unix. Post 302212827 by joeyg on Tuesday 8th of July 2008 12:21:32 PM
Old 07-08-2008
Hammer & Screwdriver Here is one apprach, although there are many ways to address this

First off, my data file (note I use pipe '|' characters between fields):
Code:
> cat sample.dat
smith|john|123-45-6789|40|usp123-45-67
jones|mary anne|111-22-1111|18|usp111-23-365
johnson|howard|333-33-3333|70|usp999-89-897

Now, the program (it does some extra displays that are more for choice):
Code:
> cat searchdata 
#! /bin/bash

echo "Enter last name"
read lname

echo "Enter first name"
read fname

echo "*****"
echo "searching for "$lname $fname
echo "*****"
matchrec=$(cat sample.dat | grep "^$lname")

if [ -n "$matchrec" ]
   then
   echo "*possible match found..." 
   ln=$(echo "$matchrec" | cut -d"|" -f1)
   fn=$(echo "$matchrec" | cut -d"|" -f2)
   if [ "$fn" = "$fname" ]
      then
      echo "*verified first name"
      ss=$(echo "$matchrec" | cut -d"|" -f3)
      ag=$(echo "$matchrec" | cut -d"|" -f4)
      pa=$(echo "$matchrec" | cut -d"|" -f5)
#display the matching data
      echo " "
      echo "First Name   :"$fn
      echo "Last Name    :"$ln
      echo "Social Sec # :"$ss
      echo "Age of person:"$ag
      echo "Passport id  :"$pa
   fi
fi

And finally, the program execution:
Code:
> searchdata
Enter last name
smith
Enter first name
john
*****
searching for smith john
*****
*possible match found...
*verified first name
 
First Name   :john
Last Name    :smith
Social Sec # :123-45-6789
Age of person:40
Passport id  :usp123-45-67
>

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Noob learning Unix: backup commands

I am trying to learn some unix here and i have some question that i would like to ask: What's the most basic backup command? What is the command to pause a backup? What is the command to resume backup? Can we backup a job that is running ? How can we pause the backup of the job and than... (1 Reply)
Discussion started by: lotusx
1 Replies

2. UNIX for Dummies Questions & Answers

I am a unix noob

Hello i am new to this forum. I signed up here really to ask one question. I recentaly got a old unix server from my work and i never really understood what unix is or what is does. Dont get me wrong i and very smart with computers as long as its windows, mac, or linux i can use them all but i... (4 Replies)
Discussion started by: alt+f4
4 Replies

3. UNIX for Dummies Questions & Answers

complete noob

Hi all, This is my first post. I am a complete noobie to the UNIX OS, I have an iMac G5 with the unix shell built in and am interested in learning how to use it to do things useful with it, but have no idea where to start. I have read over the basic commands but they haven't helped me much yet.... (3 Replies)
Discussion started by: avdrummerboy
3 Replies

4. Shell Programming and Scripting

Shell Noob

Hi all, I am trying to write a shell script that will move files from one directory to another, the only thing is I want to to check loads of different source directory and move the files to loads of different directories. I am totally new to shell scripts but not to UNIX (although I would... (16 Replies)
Discussion started by: Sax
16 Replies

5. UNIX for Dummies Questions & Answers

complete unix noob (sorry)

This is my first time in this forum so, Hello to all!!! I have been supporting windows based machines for a few years now and I have been writing batch files to do certain tasks for what seems like an age. I've recently started a new job (as it support) and my new colleagues have said,... (2 Replies)
Discussion started by: Blastman
2 Replies

6. UNIX for Dummies Questions & Answers

Unix Noob, wat do i need etc

Hey everyone I am currently starting University, (Aus) and i am required to study Unix as apart of my study. We have gone through the basics in orientation but here at home they said i can access my files through the 'ssh' command. All i need to know is: - How will my wireless internet be... (2 Replies)
Discussion started by: skylin3fr3ak
2 Replies

7. Shell Programming and Scripting

unix noob help with awk?

Hi I'm really new to this so sorry if this is trivial What I'm trying to do is take a file with 3 columns of numbers and cat all the entries of the second and third columns which have the same entry in the first column into a file with the number from the first column in the name. So say 1... (11 Replies)
Discussion started by: AnnaLynn
11 Replies

8. Linux

noob help needed

i'm having trouble putting together a program :( any help would be much appreciated! Write a Shell Program to automate the process of collecting assignments from the directories of students of any specified class. The person running the program should be able to pass a parameter to the... (1 Reply)
Discussion started by: ace_face
1 Replies

9. SCO

SCO noob please help

hello, sco openserver R5 the following error and it fails to load. init: Command is respawning too rapidily id: vm "/home/bin/stvm.sh" init: Comand..etc id: c02"/etc/start/autostart" its trying to mount car diagnostic program in vmware, the program location is in "start" i think? i... (1 Reply)
Discussion started by: hgibbs8129
1 Replies

10. Shell Programming and Scripting

Cron-Noob

Hi guys! Consider the following PERL script, #!/usr/bin/perl my $userID = `whoami`; open(TMP, ">user.txt"); print TMP "$userID"; close(TMP); Run on the command line it works no problem. Run using crontab it doesn't work. Where do I go to check errors from crontab? I've read things... (25 Replies)
Discussion started by: Jaymoney
25 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 09:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy