userlist=`who | cut -d " " -f1`
linetotal=`cat $userlist| wc -l`
linenumber='1'
while [ $linenumber -le linetotal ]
do
username=`somestuff` put that in for now
basically i want the username variable to be equal to the first line from who | cut -d " " -f1`...and from the loop move to the next line of `who | cut -d " " -f1` and so on until the loop is cleared......
User Profile
Collapse
-
Hey thanks for your reply. However i've not used awk or sed before and i'm not suppose to use it for this exercise. The full task is to use a file as an argument then display the permissions in a certain format like so :-
READ WRITE EXECUTE
OWNER LEE.BALLANCORE YES YES NO
GROUP USERS YES NO NO
EVERYBODY NO NO NO
... -
Readin File permissions?
How do i read a file permission?
i know that ls -l *filename* will list all information about the file including file permissions eg -rwxr-xr-x 1 norman.thai users 187 Jan 15 10:33 firstline...
how do i read just the file permission tho to use be used as a variable...
-rwxr-xr-x
i also understand that the file permissions can be read as binary 000 000 000... -
Thanks very much Paul, thats the type of help i wanted. I'll get cracking on it and i'll pm you my answer sometime next week for your confirmation. Thanks again much appreciated....Leave a comment:
-
-
Hey thanks for your time, both codes you provided for me work, i vaguely understand the last one...i just don't understand why my tutorials would ask me to look at loops.
If you have any time could you explain the nl -s\ command and w1 in your coding - (rm file&&nl -s\) -w1>file)<file
Thanks again you have been helpful...Leave a comment:
-
i was told to look into loops. I'm new tho i'll have a crack at what you put in....Leave a comment:
-
Have a look at what i get:-
[norman.thai@uni x ~]$ ps -U norman.thai
PID TTY TIME CMD
9681 ? 00:00:00 sshd
9682 pts/23 00:00:00 bash
9711 pts/23 00:00:00 ps
[norman.thai@uni x ~]$ w
14:07:31 up 1 day, 4:47, 24 users, load average: 0.14, 0.12, 0.10
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
amol.pan pts/1 82.28.49.174 14:03...Leave a comment:
-
I'm gona emphasise this again...this is not homework i have graduated and for a job i require to understand unix further. They have given me an online tutorial and have suggested excercises to carry out...and i am unable to do them.
So far you have critcised my knowledge. ps -U *username* structures the required information the way i want it to...however does not show me the list of all users in that foramt...
my second...Leave a comment:
-
My latest attempt is :-
ls -la|grep " $1"$ | tr "\t" " " | tr -s " " | tr " " "\n" > tfile
permissions=$(h ead -1 tfile)
owner=$(head -3 tfile|tail -1)
rm tfile
powner=$(print -- $permissions|cu t -c 2-4)
pgroup=$(print -- $permissions|cu t -c 5-7)
pusers=$(print -- $permissions|cu t -c 8-10)
print Filename: $1
print...Leave a comment:
-
Listing logged on users
I want to create a file that shows all the users logged into the system and their processes. I've tried using the w command...this lists a little too much information...s o i tried using
ps -U *myusername* but that only gave me my current logged on status in the following correct format:-
PID TTY TIME CMD
31799 pts/3 00:00:00 vim
31866 pts/3 00:00:00 vim
2495 pts/7 00:00:00 vim
8368 pts/0... -
An alternative to this code?
Does anyone know an alternative to this without the use of awk or a tmp file. I'm starting from the basics and awk seems a wee bit too advanced at this early stage. Kind regards.
awk '$0=++c")"$0' file>_tmp&&mv _tmp file
i have a feeling i need to use a loop. -
Hi Jeff, thanks for the reply.
This isn't homework, its an exercise apparrently designed to further my learning. However i'm not learning. I've been asked to further research on how to code this. Let me add, i am a complete newbie to unix. I'm familiar with the bash interface but scripting i'm finding hard to grasp. So far from my online training i've come across the the chmod command which is for permissions. I understand echo will...Leave a comment:
-
Is there a method without awk cos i'm learning from the basics and i've used tmp files before but i want a way without using a tmp file. Thanks...Leave a comment:
-
Unix script for permissions
How do i write a script that takes a file as an argument and determines what permissions the owner, group and everybody has for the file?
I want to view roughly like this.
READ WRITE EXECUTE
OWNER MATT.BALLANCORE YES YES NO
GROUP USERS YES NO NO
EVERYBODY NO NO NO -
Unix Adding Text to corresponding lines...
grep $USER xx >> filenorman.thai
i used the above command to gain a searched list for a user and put it into a file called filenorman.thai , the following is a bit of its contents...
USER=norman.tha i
MAIL=/var/spool/mail/norman.thai
PWD=/home/norman.thai
HOME=/home/norman.thai
My question is, how do i add the corresponding line number as well as a bracket to make the text look...
No activity results to display
Show More
Leave a comment: