01-12-2007
Complex Sed/Awk Question?
Hello,
So i have this file called /apps/turnout which looks like that of the contents of the /etc/shadow (but not exactly)
the file has a long list in it. basically, the contents of this file looks something similar to the following:
jajajajalala:D#$#AFVAdfda
lalabavisof:#%R@fafla#$
anthovolad:#%)@#Fafdf834
The first field is the username, the second field is something else.
now, how can i insert a new username into the this file in a alphabetical order without actually going into the file. i hate having to vi/emacs/ed or whatever when i dont have to.
so, in otherwords, say i have a name like:
mjackson:#$#$#$%adf#$#
and i want to insert it into the file /apps/turnout so it is placed inside the file in its alphabetical place, how do i accomplish that from the command line.
(i dont want to do the other technique of copying the original file, editing the copy and then rewriting the original.)
Last edited by Perderabo; 01-12-2007 at 02:43 PM..
Reason: disable smilies for readability
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have some text:
0400-0427 NA Czech Republic R. Prague 5990ca, 6200, 7345
0400-0456 NA, As Romania R. Romania Int'l 6115, 9515, 9690,
11895
0400-0500 NA U. S. A. WYFR 6065, 6855, 9505,
9715
0400-0500 NA,Eu,Af U. S. A. ... (8 Replies)
Discussion started by: petebear
8 Replies
2. UNIX for Advanced & Expert Users
Hi I have a pattern like this. repeating many lines
CHANGE #13 TYP:22 CLS: 21 AFN:12 DBA:0x0040a15f OBJ:41142 SCN:0x0000.00036b3e SEQ:1 OP:11.2
CHANGE #15 TYP:32 CLS: 32 AFN:212 DBA:0x0040a15f OBJ:41143 SCN:0x0000.00046b3e SEQ:1 OP:13.3
.
And i am trying to do the following:
a) I need to get... (2 Replies)
Discussion started by: hare
2 Replies
3. Shell Programming and Scripting
hello,
I have this in a file
server_name=DB1
hostname=db1
I want to change hostname value to `hostname`. Any idea?
and server_name value to toUPPER (`hostname`). Any idea?
thanks (3 Replies)
Discussion started by: melanie_pfefer
3 Replies
4. UNIX for Dummies Questions & Answers
Hi,
I have to write a script that goes through every *.cpp file in the current directory and if any file has #includes of non-system header files (those with double quotes around them), then I need to print out those header files within the quotes. I've figured out how to run a for loop and find... (4 Replies)
Discussion started by: MEllis5
4 Replies
5. Shell Programming and Scripting
Hello expert, I have an output file with few thousand lines similar like below : "Future Netmgmt" "10.99.16.0" "N" "10" "10.0.0.0" "Circuitless-IP" " " "255.255.254.0" "Future Netmgmt" "10.99.18.0" "N" "10" "10.0.0.0" "Circuitless-IP" " " "255.255.254.0" "WAAS loopbacks" "10.99.20.0"... (6 Replies)
Discussion started by: dannytrinh
6 Replies
6. Shell Programming and Scripting
Unix Guru's ,
I have a file all_files.txt containing data as follows
all_files.txt
first file : /a/b/c/file.sh first second CLIENT1
second file : /a/b/c/file.sh first second CLIENT1
first file : /a/b/c/file.sh first second CLIENT2
second file : /a/b/c/file.sh first second... (6 Replies)
Discussion started by: jville
6 Replies
7. Shell Programming and Scripting
Hi,
I have a file look likes this :
--->start hir
Trace file: pudwh_ora_9998.trc
Sort options: fchela exeela
***************************************************************count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed... (3 Replies)
Discussion started by: yoavbe
3 Replies
8. Shell Programming and Scripting
I have a file that contains RewriteRules for 200 countries (2 examples for 1 country below):
RewriteRule ^/at(/|/index.html|)$ http://%{HTTP_HOST}/locate/index.html?locale=de_AT
#&
RewriteRule ^/at_english(/|/index.html|)$ http://%{HTTP_HOST}/locate/index.html?locale=en_AT
I have... (5 Replies)
Discussion started by: usshadowop
5 Replies
9. Programming
Dear All,
I am having a requirement to find the difference between 2 files and generate a discrepancy report out of it as an html page. I prefer using diff -y file1 file2 since it gives user friendly layout to know any discrepancy in the record and unique records among the 2 file. Here's how it... (12 Replies)
Discussion started by: Badhrish
12 Replies
10. Shell Programming and Scripting
Hi, I'm not very familiar witrh sed or awk and hope the somebody can help me to solve my problem. I need to filter a text report using grep, sed or awk. I would like to cut out text lines with the pattern INFO and if exists the following lines of the pattern DETAILS. I need te keep the lines with... (4 Replies)
Discussion started by: Frankg
4 Replies