Sponsored Content
Top Forums UNIX for Advanced & Expert Users creating a file by editing another one? Post 302251267 by otheus on Sunday 26th of October 2008 04:35:10 AM
Old 10-26-2008
awk would be best.
Code:
awk -F: '$6 ~ /^\/home\/inst/ { $7="/bin/sh"; print; } {print}' /etc/passwd >copy-passwd

This isn't exactly what you asked for, but I think it's what you want. If you really don't want the other entries (the ones that have no /home/inst for a home dir), then remove the "{print}".
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Editing the end of the file without loading the entire file

hi! I am a newbee. I would really appreciate if you can answer the following question: I have a huge data file, 214MB with several coloumns. I need to delete the very last line of the file. Everything I know takes a lot of time to do it ( because I have to open the file in an editor or run a... (3 Replies)
Discussion started by: Garuda
3 Replies

2. Shell Programming and Scripting

Editing file

Hi, I am in a situation wherein am getting file file certailn values suppose 1u56979hhghhklklkkkjkjkjk 0 0 0 The file will have values like above only. I need to add another field of NULL value(of length 9) at the end of first column i.e. It should like this after editing:... (4 Replies)
Discussion started by: rahul303
4 Replies

3. Ubuntu

Avoid creating temporary files on editing a file in Ubuntu

Hi, My ubuntu flavor always create temporary files having filename followed by ~ on editing. For eg: if I am editing a file called "sip.c", automatically a temporary (bkup) file is getting created with the name "sip.c~". How to avoid this file creation? (7 Replies)
Discussion started by: royalibrahim
7 Replies

4. Linux

file editing

I have created a file with vi -x (file name) this is encrypted file when i again open this file it ask me to enter a password before editing it.Can i remove this password but i don't want to delete a file how to do this. Thanks (0 Replies)
Discussion started by: ambavaram
0 Replies

5. Shell Programming and Scripting

Editing a File

Hi all, I have a file with following contents # rad124 # radkus # raddebug # radtrace I could like to remove the # and space present before the key word "rad". Any ways to do this using "subsitution method(:%s/old/new/g)" will be hepful. (1 Reply)
Discussion started by: ramkriz
1 Replies

6. Shell Programming and Scripting

editing a file

i am writing a script to edit entries in a file. what command will edit a specific file? ex: echo) "what number would you like to change read "number" this is where I am stuck. what command will edit my specific file? (3 Replies)
Discussion started by: gustave
3 Replies

7. Shell Programming and Scripting

Help with file editing while keeping file format intact

Hi, I am having a file which is fix length and comma seperated. And I want to replace values for one column. I am reading file line by line in variable $LINE and then replacing the string. Problem is after changing value and writing new file temp5.txt, formating of original file is getting... (8 Replies)
Discussion started by: Mruda
8 Replies

8. Shell Programming and Scripting

editing line in text file adding number to value in file

I have a text file that has data like: Data "12345#22" Fred ID 12345 Age 45 Wilma Dino Data "123#22" Tarzan ID 123 Age 33 Jane I need to figure out a way of adding 1,000,000 to the specific lines (always same format) in the file, so it becomes: Data "1012345#22" Fred ID... (16 Replies)
Discussion started by: say170
16 Replies

9. Shell Programming and Scripting

File editing with out creating a new file

I need edit some characters in a file, but without creating intermediatory file and also one liner. I tried: cat foo.txt | sed '/s/abc//g' > foo.txt cat foo.txt | sed '/s/abc//g' >> foo.txt First one is making foo.txt to zero byte, while second one is appending my desired output... (4 Replies)
Discussion started by: karumudi7
4 Replies

10. Shell Programming and Scripting

Convert vi editing to text editing

Dear Guru's I'm using Putty and want to edit a file. I know we generally use vi editor to do it. As I'm not good in using vi editor, I want to convert the vi into something like text pad. Is there any option in Putty to do the same ? Thanks for your response. Srini (6 Replies)
Discussion started by: thummi9090
6 Replies
FGETPWENT(3)						     Linux Programmer's Manual						      FGETPWENT(3)

NAME
fgetpwent - get password file entry SYNOPSIS
#include <pwd.h> #include <stdio.h> #include <sys/types.h> struct passwd *fgetpwent(FILE *stream); DESCRIPTION
The fgetpwent() function returns a pointer to a structure containing the broken out fields of a line in the file stream. The first time it is called it returns the first entry; thereafter, it returns successive entries. The file stream must have the same format as /etc/passwd. The passwd structure is defined in <pwd.h> as follows: struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* user password */ uid_t pw_uid; /* user id */ gid_t pw_gid; /* group id */ char *pw_gecos; /* real name */ char *pw_dir; /* home directory */ char *pw_shell; /* shell program */ }; RETURN VALUE
The fgetpwent() function returns the passwd structure, or NULL if there are no more entries or an error occurs. ERRORS
ENOMEM Insufficient memory to allocate passwd structure. FILES
/etc/passwd password database file CONFORMING TO
SVID 3 SEE ALSO
getpwnam(3), getpwuid(3), getpwent(3), setpwent(3), endpwent(3), getpw(3), putpwent(3), passwd(5) GNU
1996-05-17 FGETPWENT(3)
All times are GMT -4. The time now is 09:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy