Computing.Net > Forums > Unix > c shell script help PLEASE

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

c shell script help PLEASE

Reply to Message Icon

Name: Sharan
Date: December 12, 2002 at 11:12:21 Pacific
OS: sun 5.8
CPU/Ram: sun 5.8
Comment:

Please help me on two shell scripts:

1. the script simulates the ls -l command but prints only three columns of our choice.

2. the script makes a file out of the information in the etc/passwd. file using the following format:
User Name User ID Group ID Home Directory

Apericiate your help deeply.

Sharan



Sponsored Link
Ads by Google

Response Number 1
Name: struzzo
Date: December 12, 2002 at 23:10:27 Pacific
Reply:

Hi,

i think this is your homework! I don't tell you the full solution.
But have a look into the awk manpages!!!

Have a nice day

greets struzzo


0

Response Number 2
Name: Sharan
Date: December 13, 2002 at 20:07:06 Pacific
Reply:

You are right. That's my homework. I've been staring at them for three weeks. I believed that if my book knows how to complain, I am in the jail right now (because I abused it badly). The book doesn't really help a beginner beginner like me. Anyway, that's for your help!

Sharan


0

Response Number 3
Name: David Perry
Date: December 27, 2002 at 12:43:14 Pacific
Reply:

awk deals with input generally separated by spaces but can be forced to use other field separators.

ls -l | awk '{ print $1 " " $4 }'

will print the first column, a space and the fouth column

cut can deal with any single character as a field delimitor, but in this case it would be easier to name the field separator in awk

echo "User Name (gecos) userid home directory" > outfile
cat /etc/passwd | \
awk --field-separator : \
'{print $5 " " $1 " " $6}' >> outfile

O'Reilly has a great book covering sed and awk.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: c shell script help PLEASE

C-shell script help www.computing.net/answers/unix/cshell-script-help/6828.html

C Shell script help! www.computing.net/answers/unix/c-shell-script-help/3108.html

C Shell Script Help www.computing.net/answers/unix/c-shell-script-help/7095.html