I have a bash script and tried very hard but i couldn't solve it please help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I have a bash script and tried very hard but i couldn't solve it please help
# 8  
Old 10-19-2010
and what about the second one
2- If no arguments are give, the script should identify normal users in the system (UID >= 500) and for each user, reset files permissions as described above.

---------- Post updated at 01:11 PM ---------- Previous update was at 12:17 PM ----------

and what about the second one
2- If no arguments are give, the script should identify normal users in the system (UID >= 500) and for each user, reset files permissions as described above.
# 9  
Old 10-19-2010
I would do that in a wrapper, and call the separately tested child script from it. It simplifies testing of both. If you want, later one can be a function within the other.

cut, sed or awk could find the /etc/passwd fields you need, and selectively invoke the script. Somewhere, ensure the home dir exists or is gracefully logged and ignored!

Code:
sed '
  s/^[^:]*:[^:]*:\([^:]*\):[^:]*:[^:]*:\([^:]*\):.*/\1 \2/
  /^[0-9]\{0,2\} /d
  /*[0-4][0-9][0-9] /d
  / \/$/d
  / $/d
  s/^/your_script /
 ' /etc/passwd >all_script

Narrative: Pull fields 3 and 6, colon : separated, from /etc/passwd, now separated by a space; if 3, the user #, is 0 to 2 digits, or if it is three digits starting 0-4, it is too low. If the nominal home dir is '/', we don't want to do this. If there is no home dir, we don't want to try. Stick your script on the front of every line.

Last edited by DGPickett; 10-19-2010 at 03:42 PM..
# 10  
Old 10-19-2010
L will try it now .
# 11  
Old 10-19-2010
Enjoy, but be careful!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to solve query

Hi I have data in the below format in two columns in excel which i will copy to notepad. test as rec1, string test as rec2, byteint test as rec3, string update date as test, datetime name as tes2 string I need to add trim function on all the string columns and keep the remaining... (10 Replies)
Discussion started by: pisikar
10 Replies

2. Shell Programming and Scripting

How to solve hang issue in script?

i have one function block in the beginning of my script and there are some commands inside that function which will perform some operations. And i am invoking that function from my main script by passing some values. Sometimes it is hanging in the middle for some value. For example: For 1st... (3 Replies)
Discussion started by: thomasraj87
3 Replies

3. Shell Programming and Scripting

Script to solve second order (polynomial) interpolation

Currently I have awk command to do linear interpolation awk ' { P=$2 I=$1 } END { j=0; s=I; t=I for(i=m;i<=n;i++) { if(I && i>t) { j++; s=I; t=I } print i, P+(i-s)*(P-P)/(t-s) } } ' m=1 n=8 infile FILE CONTENT... (8 Replies)
Discussion started by: Tzeronone
8 Replies

4. Shell Programming and Scripting

'Couldn't read file' error in bash script with expect, sed and awk!

Ok, so I have a bash script with an embedded expect statement. Inside of the expect statement, i'm trying to pull all of the non-comment lines from the /etc/oratab file one at a time. Here's my command: cat /etc/oratab |sed /^s*#/d\ | awk 'NR==1'|awk -F: '{print \"$1\"}'|. oraenv Now,... (0 Replies)
Discussion started by: alexdglover
0 Replies

5. Shell Programming and Scripting

Bash or awk script to solve this problem

Hi everybody! I have written some awk scripts that return me some results I need to process. At the moment I use openOffice to process them, but I am trying to find a more efficient solution using possibly a bash or awk script. I have two files, file1 is in the format: time position ... (3 Replies)
Discussion started by: Alice236
3 Replies

6. UNIX for Advanced & Expert Users

Help! SHELL or AWK script - only the masters of the forum will solve

Hello everybody! I have no experience with shell Programmer, but I need to compare 02 files. Txt and generate an output or a new file, after the comparisons. see: If the column 1 of file1 is equal to column 1 of file2, and column 3 of file2 contains the column 4 of file1, output: column1... (4 Replies)
Discussion started by: He2
4 Replies

7. Shell Programming and Scripting

Help me to solve some question about shell Script

Factorial calculation Example output: Please enter a non-negative number: 3 3! = 3 X 2 X 1 = 6 Please enter a non-negative number: 10 10! = 10 X 9 X 8 X 7 X 6 X 5 X 4 X 3 X 2 X 1 = 3628800 Please enter a non-negative number: -1 ... (1 Reply)
Discussion started by: cenco
1 Replies

8. Shell Programming and Scripting

Help me to solve some question about shell Script

Factorial calculation Example output: Please enter a non-negative number: 3 3! = 3 X 2 X 1 = 6 Please enter a non-negative number: 10 10! = 10 X 9 X 8 X 7 X 6 X 5 X 4 X 3 X 2 X 1 = 3628800 Please enter a non-negative number:... (1 Reply)
Discussion started by: cenco
1 Replies

9. Shell Programming and Scripting

Unix shell script couldn't be executed. Pls help!

I have wrriten a script to call sql script to do some work in database. However, the script couldn't be executed. The only information was: ksh: ./updt_attrib.ksh cannot execute. Please help me to identify where the problem is. I post script here for your reference. Thanks a lot. #!/bin/ksh ... (8 Replies)
Discussion started by: duke0001
8 Replies
Login or Register to Ask a Question