Sponsored Content
Top Forums Shell Programming and Scripting Grabbing text and using that text in a newly created line Post 302565623 by mafia910 on Tuesday 18th of October 2011 11:28:54 AM
Old 10-18-2011
Grabbing text and using that text in a newly created line

Hello,

I am really stuck and I'm hoping somone can help. I have a text file that is similar to this:

Code:
<--First User-->
<function>account='uid=user1,.......
 
<--Second User-->
<function>account='uid=user2,.......

What I want is to grab the usernames after "uid=" and before the following comma. I cannot figure this out.

I then need to add a new line to each user's section. This new line is the same for all users, with the exception of needing the specific username for that user. For example I would like it to do this:

Code:
<--First User-->
<function>account='uid=user1,.......
<newlycreatedline>hello my name is user1......
 
<--Second User-->
<function>account='uid=user2,.......
<newlycreatedline>hello my name is user2......

Anyone know how to script this out, I need this done for too many users to do it by hand.
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 10-18-2011 at 12:40 PM.. Reason: code tags please!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding specific text and spaces to each line in a text file

Hi, I wanted to add specific text to each row in a text file containing three rows. Example: 0 8 7 6 5 5 7 8 9 0 7 9 7 8 9 0 1 2 And I want to add a 21 at the beginning of the first row, and blank spaces at the beginning of the second two rows. To get this: 21 0 8 7 6 5 5 7 8... (4 Replies)
Discussion started by: hertingm
4 Replies

2. Shell Programming and Scripting

How to insert some constant text at beginig of each line within a text file.

Dear Folks :), I am new to UNIX scripting and I do not know how can I insert some text in the first column of a UNIX text file at command promtp. I can do this in vi editor by using this command :g/^/s//BBB_ e,g I have a file named as Test.dat and it containins below text: michal... (4 Replies)
Discussion started by: Muhammad Afzal
4 Replies

3. Shell Programming and Scripting

Search text from a file and print text and one previous line too

Hi, Please let me know how to find text and print text and its previous line. Please don't get irritated few days back I asked text and next line. I am using HP-UX 11.11 Thanks for your help. (6 Replies)
Discussion started by: kamranjalal
6 Replies

4. Shell Programming and Scripting

grabbing filename from text file....should be easy!

Quick question...I'm trying to grab the .tif file name from this output from our fax server. What is the best way i can do this in a bash script? I have been looking at regular expressions with bash or using awk but having some trouble. thanks! The only output i want is... (5 Replies)
Discussion started by: kuliksco
5 Replies

5. Shell Programming and Scripting

How to find the newly created directory

Hi, I need to create new directory by increasing the number by 1 of extracted lastly created directory. e.g. Log\out_log_1\ Log\out_log_2\ Log\out_log_3\ become Log\out_log_1\ Log\out_log_2\ Log\out_log_3\ Log\out_log_4\ Can anyone help how to do it in c-shell... (3 Replies)
Discussion started by: Andre_2008
3 Replies

6. Shell Programming and Scripting

Grabbing top line of text in a file and setting it to a variable

If I have a txt file with test.txt somelineoftext and I want to set that line of text to variable in a script: so #!/bin/bash var='' becomes #!/bin/bash var='somelineoftext' (3 Replies)
Discussion started by: digitalviking
3 Replies

7. Shell Programming and Scripting

Grabbing a chunk of text from a file

Hi, I have a Report.txt file. Say the contents of this file are : 1 2 3 4 5 7 df v g gf e r dfkf lsdk dslsdklsdk Report Start: xxxxxxdad asdffsdfsdfsdfasfasdffasdf sadfasdfsadffsfsdf Report End. sdfasdfasdf sdfasfdasdfasdfasdfasdf sadfasdfsdf I need to grab from Report Start... (3 Replies)
Discussion started by: mrskittles99
3 Replies

8. Hardware

Formatting a newly created lun

Hi , I have created one new lun in my SAN storage and make it visible to my HP servers , but the fdisk -l output is somehow confusing. Do not know what to do next ---------- fdisk -l /dev/sdo1 Disk /dev/sdo1 (Sun disk label): 64 heads, 32 sectors, 10238 cylinders Units =... (7 Replies)
Discussion started by: mishra.sankar
7 Replies

9. Shell Programming and Scripting

Grabbing data between 2 points in text file

I have a text file that shows the output of my solar inverters. I want to separate this into sections. overview , device 1 , device 2 , device 3. Each device has different number of lines. but they all have unique starting points. Overview starts with 6 #'s, Devices have 4#'s and their data starts... (6 Replies)
Discussion started by: Mikey
6 Replies

10. Shell Programming and Scripting

Grabbing text between two lines with shell variables.

I would like to grab complex html text between lines using variables. I am running Debian and using mksh shell. Here is the part of the html that I want to extract from. I would like to extract the words 'to love,' and I would like to use the above and below lines as reference points. ... (3 Replies)
Discussion started by: bedtime
3 Replies
eurephiadm users(7)													       eurephiadm users(7)

NAME
eurephiadm-users - User management module SYNOPSIS
eurephiadm users --list|-l [-S|--sort <sort keys>] eurephiadm users --show|-s [-i|--uid <user id>] [-u|--username <user name>] [-l|-|-lastlog] [-L|--lastlog-details] [-a|--attempts] [-b|--blacklist] eurephiadm users --activate|-a [-i|--uid <user id>] [-u|--username <user name>] eurephiadm users --deactivate|-d [-i|--uid <user id>] [-u|--username <user name>] eurephiadm users --add|-A [-u|--username <user name>] [-P|--password <plain text password>] [-C|--certid <certificate ID>] [-D|--digest <certificate SHA1 digest>] [-c|--certfile <certificate file>] [-2|--pkcs12] eurephiadm users --delete|-D [-i|--uid <user id>] [-u|--username <user name>] eurephiadm users --password|-p [-i|--uid <user id>] [-u|--username <user name>] eurephiadm users [-h|--help [<mode>]] DESCRIPTION
eurephiadm users manages eurephia user accounts. It provides an interface for listing, creating new, modify and delete user accounts. MODES
Available modes: -l | --list [-S|--sort <sort keys>] List all user accounts. Providing -S|--sort and a sort key will define the sort order of the list. Valid sort keys are: uid - user ID username - User name belonging to the user account activated - When the user account was activated deactivated - When the user account was deactivated lastaccess - When the user account was last used -s | --show [-i|--uid <user id>] [-u|--username <user name>] [-l|--lastlog] [-L|--lastlog-details] [-a|--attempts] [-b|--blacklist] Show user account details. --uid or --username are required. The other arguments only defined which kind of information to show. -a | --activate [-i|--uid <user id>] [-u|--username <user name>] Activate a user account. --uid or --username is required. -d | --deactivate [-i|--uid <user id>] [-u|--username <user name>] Deactivate a user account. --uid or --username is required. -A | --add [-u|--username <user name>] [-P|--password <plain text password>] [-C|--certid <certificate ID>] [-D|--digest <certificate SHA1 digest>] [-c|--certfile <certificate file>] [-2|--pkcs12] Add a new user account. --username is required. If you want to assign a password for the new user account via the command line, provide the password with --password. To associate this user account against an already regstistered certificate, it can be done by either refering to the certificate ID in eurephia using --certid or providing the certificate SHA1 digest/fingerprint to --digest. A brand new certificate can be registered and linked to the user account directly if you have access to the certificate file. The file can be in either PEM/DER format or PKCS#12. Use --certfile to indicate the certificate file to extract the information from and --pkcs12 if it is a PKCS#12 file. -D | --delete [-i|--uid <user id>] [-u|--username <user name>] Delete a user account. --uid or --username is required. -p | --password [-i|--uid <user id>] [-u|--username <user name>] Change password on a user account. --uid or --username is required. -h | --help [<mode>] Show a help screen. Without any arguments, all modes are listed. Providing a mode will show more information about the chosen mode. SEE ALSO
eurephiadm(7), eurephiadm-certs(7) AUTHOR
Copyright (C) 2008-2010 David Sommerseth <dazo@users.sourceforge.net> David Sommerseth July 2010 eurephiadm users(7)
All times are GMT -4. The time now is 03:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy