Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Hide output of a certain file on print Post 303035754 by joonisio on Sunday 2nd of June 2019 07:39:34 AM
Old 06-02-2019
Hide output of a certain file on print

Im trying to print /etc/passwd with a variable connecting to /etc group/
But when im trying to print the output, /etc/group is printing also. Can i ask for help on what command to use
so it will ignore /etc/group and only print /etc/passwd.

here's the sample script. pages number and the /10 entry line pages should be used also.

Code:
 awk -F":" -v A=$(wc -l < /etc/passwd) '
    BEGIN   {
            NUM_PAGES=A/10+1
            print "--------------------------------------------------"
            printf "%-20s %-20s %-3s\n","USERNAME","GUID","DIRECTORY"
            print "--------------------------------------------------"
            }

   !(NR%10) {
             PAGE++
             printf "--- Page %d of %d ---",PAGE,NUM_PAGES
             getline rc < "-"; system("tput cuu1")
            }

   (NR==FNR){
            B[$3]=$1
            next } $4 in B { $4=B[$4]
            }


            { printf "%-20s %-20s %-3s\n", $1, $4, $7 }

' /etc/group /etc/passwd

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need to hide output to screen

I have a script that askes users to enter in an oracle account and password, The information is displayed on the screen as they type it. Does anyone know how I can hide this output? :confused: (1 Reply)
Discussion started by: boat73
1 Replies

2. Shell Programming and Scripting

print out a line from a output file

I am trying to have a script ping all the clients then output it to a file so I know which clients are off then have the next script pull the ones that are online and reboot them. This is what I am running with right now. If there is something KISS then by all means please let me know. ... (3 Replies)
Discussion started by: deaconf19
3 Replies

3. Shell Programming and Scripting

Print permissions for a file in output

hi i m trying to print the permissions for a file in output echo name read name touch name.txt permission=$((ls -l $name.txt)) echo permission please suggest where i went wrong? (2 Replies)
Discussion started by: angel12345
2 Replies

4. Shell Programming and Scripting

How to print prstat -Z output into a file?

Hi Expert, I want to print CPU and Memory utilization into a text file. I am using "prstat -Z" to see the output on screen. When I run below command prstat -Z | grep httpd | awk '{print$3} '>> output.txt but it is not printing to file. Also I want to be below header on output PID USERNAME ... (6 Replies)
Discussion started by: lalit kumar
6 Replies

5. Shell Programming and Scripting

Print a column with the name of the output file

I have n files and I am using cat to combine them in to one. Before that simply add the name of the output file to 4th column and then print the output. Is it possible ? input1 chr start end name 0 + key input2 chr start end name 0 + key inputn... (1 Reply)
Discussion started by: quincyjones
1 Replies

6. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

7. Shell Programming and Scripting

Run a program-print parameters to output file-replace op file contents with max 4th col

Hi Friends, This is the only solution to my task. So, any help is highly appreciated. I have a file cat input1.bed chr1 100 200 abc chr1 120 300 def chr1 145 226 ghi chr2 567 600 unix Now, I have another file by name input2.bed (This file is a binary file not readable by the... (7 Replies)
Discussion started by: jacobs.smith
7 Replies

8. Shell Programming and Scripting

Hide the output of spawn ssh user@server

Hi All, I have written one script, which is connecting 3 diffrent servers and executing script placed on those. It is smthing like: spawn ssh user@server1 expect "*? assword:" send "pw \r" expect "$" send " sh ./filename1 \r" expect "$" expect eof spawn ssh user@server2 expect "*?... (7 Replies)
Discussion started by: KDMishra
7 Replies

9. Programming

How to hide from UNIX strings - obfuscate or hide a literal or constant?

Hi, I need to somehow pipe the password to a command and run some SQL, for example, something like echo $password | sqlplus -s system @query01.sql To make it not so obvious, I decided to try out writing a small C program that basically just do echo $password. So now I just do x9.out | sqlplus... (8 Replies)
Discussion started by: newbie_01
8 Replies

10. Shell Programming and Scripting

Print the output with different file names

I have a python script that gives output called test.png. By using the following command I run the script every 2 seconds. What is the easiest way to save the output as follows ( test.png (1st output), tes1.png (second output), tes2.png ....) Command I i use while sleep 2; do python... (1 Reply)
Discussion started by: quincyjones
1 Replies
pwck(1M)						  System Administration Commands						  pwck(1M)

NAME
pwck, grpck - password/group file checkers SYNOPSIS
/usr/sbin/pwck [filename] /usr/sbin/grpck [filename] DESCRIPTION
pwck scans the password file and notes any inconsistencies. The checks include validation of the number of fields, login name, user ID, group ID, and whether the login directory and the program-to-use-as-shell exist. The default password file is /etc/passwd. grpck verifies all entries in the group file. This verification includes a check of the number of fields, group name, group ID, whether any login names belong to more than NGROUPS_MAX groups, and that all login names appear in the password file. grpck also issues a warning if it finds an entry (a single line) in the group file longer than 2047 characters. Such an entry causes group maintenance commands, such as groupdel(1M) and groupmod(1M), to fail. The default group file is /etc/group. All messages regarding inconsistent entries are placed on the stderr stream. FILES
o /etc/group o /etc/passwd ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
groupdel(1M), groupmod(1M), getpwent(3C), group(4), passwd(4), attributes(5) DIAGNOSTICS
Group entries in /etc/group with no login names are flagged. Group file 'filename' is empty The /etc/passwd or /etc/group file is an empty file. cannot open file filename: No such file or directory The /etc/passwd or /etc/group file does not exist. NOTES
If no filename argument is given, grpck checks the local group file, /etc/group, and also makes sure that all login names encountered in the checked group file are known to the system getpwent(3C) routine. This means that the login names may be supplied by a network name service. SunOS 5.11 27 Aug 2008 pwck(1M)
All times are GMT -4. The time now is 08:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy