Need Help with Awd/sort commands


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need Help with Awd/sort commands
# 1  
Old 12-05-2003
Need Help with Awd/sort commands

Can anyone give me a hand with some questions by e-mailing me directly, so I can relay the questions inorder. I really would appreciate anyone that can help.

Thank You in advance, I am online and will reply instantly.

Charley

<email removed>

Last edited by oombera; 02-12-2004 at 11:52 AM..
# 2  
Old 12-05-2003
Emails outside of the forum defeat the purpose of UNIX.com. Knowledge discussed outside of the forum doesn't allow everyone to benefit and fails to build the knowledge base. Your questions is not appropriate, please post your question instead of asking for one-on-one help.

Keith
# 3  
Old 12-05-2003
I planned on posting it after I was through, hard to describe something when you can not walk someone through it.

Charley
# 4  
Old 12-06-2003
I have a good awk book on my site that may be of some help.
Awk is an awesome and an extermely powerful language.

http://www.duffin.org/books/unix/sedawk/index.htm

Keith
////////////////////////////////////////////////////////////////////////////////////////////////////
Ok,

The site gave me some light to see how I can make this work.

Just one thing can you give me an example of how I can run a program that
asked the user for input to sort the items?

Charley

////////////////////////////////////////////////////////////////////////////////////////////////////
nawk is more robust than awk and has some functions like readline etc.
You could also use shell for user interaction and pass the variable into
the awk script - just a crude example:
Code:
echo "Phonelist"
echo "------------------"
echo "1) Firstname"
echo "2) Lastname"
echo "etc...\n"
echo "How would you like to sort the list? \c"
read SORTVAL
echo $SORTVAL

awk '
        BEGIN { print $sval
        }
{
        if (sval == 1) print "Will sort by Firstname"
        if (sval == 2) print "Will sort by Lastname"

}' sval=$SORTVAL phonebook

added code tags for readability --oombera

Last edited by oombera; 02-19-2004 at 12:25 PM..
# 5  
Old 12-06-2003
Sounds like this may be a more appropriate question for your teacher...I'm sure if you use the Search function of this website you'll come up with something. If it's not homework, can you be more specfic as to what your needs are?
# 6  
Old 12-06-2003
I am working to learn basic unix command such as Roster Phonelist, and simple problems since that is the system I have to use right now while I am working overseas. These are sample examples that I can use for better understanding of the syntax.

I am not in a class.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sending output of program into subsequent commands (i.e. awk/sort)

Hi, I have identified how to use command chaining as per below on a file, to capture the header of a file, as well as the line containing the C: drive. $ cat test.txt Filesystem Size Used Avail Use% Mounted on rootfs 237G 153G 84G 65% / none 237G 153G 84G ... (6 Replies)
Discussion started by: sand1234
6 Replies

2. UNIX for Beginners Questions & Answers

Extract delta records using with "comm" and "sort" commands combination

Hi All, I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file. comm -3 < sort file_old < sort file_new > new_file I am getting the below error: -ksh: sort: cannot open But if I do... (7 Replies)
Discussion started by: njny
7 Replies

3. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

Hi Experts, I have a filelist collected from another server , now want to sort the output using date/time stamp filed. - Filed 6, 7,8 are showing the date/time/stamp. Here is the input: #---------------------------------------------------------------------- -rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies

4. Shell Programming and Scripting

Help with sort word and general numeric sort at the same time

Input file: 100%ABC2 3.44E-12 USA A2M%H02579 0E0 UK 100%ABC2 5.34E-8 UK 100%ABC2 3.25E-12 USA A2M%H02579 5E-45 UK Output file: 100%ABC2 3.44E-12 USA 100%ABC2 3.25E-12 USA 100%ABC2 5.34E-8 UK A2M%H02579 0E0 UK A2M%H02579 5E-45 UK Code try: sort -k1,1 -g -k2 -r input.txt... (2 Replies)
Discussion started by: perl_beginner
2 Replies

5. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

6. Shell Programming and Scripting

How to Sort Floating Numbers Using the Sort Command?

Hi to all. I'm trying to sort this with the Unix command sort. user1:12345678:3.5:2.5:8:1:2:3 user2:12345679:4.5:3.5:8:1:3:2 user3:12345687:5.5:2.5:6:1:3:2 user4:12345670:5.5:2.5:5:3:2:1 user5:12345671:2.5:5.5:7:2:3:1 I need to get this: user3:12345687:5.5:2.5:6:1:3:2... (7 Replies)
Discussion started by: daniel.gbaena
7 Replies

7. 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

8. UNIX for Dummies Questions & Answers

Using the Sort, Cut, and Awk commands

Hello, I am trying, utilizing the few commands I know, to extract all records within my file that were generated in November of 2007. Each record within the file has a "date" field giving the month, day, and year (9-8-88). How do I extract those records to their own file? Once I extract... (4 Replies)
Discussion started by: babbabooey
4 Replies

9. AIX

How to use cat and sort commands combinations?

Hi, I need to get five names as input and sort it. It has to be done in the command level only. It should not read from any files. I tried with many combinations. I didnt get it. I can able to get the input using cat > sample jik njvi abifj ...like this and i dont know how to sort... (4 Replies)
Discussion started by: Yamini Thoppen
4 Replies

10. Programming

code that reads commands from the standard i/p and executes the commands

Hello all, i've written a small piece of code that will read commands from standard input and executes the commands. Its working fine and is execting the commands well. Accepting arguments too. e.g #mkdir <name of the directory> The problem is that its not letting me change the directory i.e... (4 Replies)
Discussion started by: Phrozen Smoke
4 Replies
Login or Register to Ask a Question