File mgt: Do you know the command line command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File mgt: Do you know the command line command
# 1  
Old 06-19-2009
File mgt: Do you know the command line command

I need a commnad to modify a file's contents from:

2009-06-18 14:14:38 CST INF Thread-114 rlo.aaf_ - MASSHANDLE: Got a valid message<Location=""><bob>2</bob><carol>61</carol><ted>54</ted><alice>1m</alice>

to this :

2009-06-18 14:14:38 CST INF Thread-114 rlo.aaf_ - MASSHANDLE: Got a valid message<Location=""><bob>2</bob>
<carol>61</carol>
<ted>54</ted>
<alice>1m</alice>

Adding the CR (\n) after each </*> and preserving the contents of each field.

Thanks for any help!
# 2  
Old 06-20-2009

Code:
sed 's|</[^>]*>|&\
|g' "$file"

# 3  
Old 06-20-2009
Code:
awk '{gsub(/<\/[^>]*>/,"\\\\&\n")}1' file

# 4  
Old 06-23-2009
Thanks!

Thanks ghostdog74 & cfajohnson! Problem solved!!
# 5  
Old 06-24-2009
Code:
my $str='2009-06-18 14:14:38 CST INF Thread-114 rlo.aaf_ - MASSHANDLE: Got a valid message<Location=""><bob>2</bob><carol>61</carol><ted>54</ted><alice>1m</alice>';
$str=~	s/(<\/[^>]*>)/$1\n/;
print $str;

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Another one line command where I'd like to determine if Ubuntu or Red Hat when running command

Hello Forum, I'm making very good progress on my report thanks to the very helpful people on this forum. I've been able to successfully create my report for my Red Hat servers. But I do have a few ubuntu servers in the mix and I'd like to capture some data from them when an ssh connection is... (8 Replies)
Discussion started by: greavette
8 Replies

2. Shell Programming and Scripting

Perl command line option '-n','-p' and multiple files: can it know a file name of a printed line?

I am looking for help in processing of those options: '-n' or '-p' I understand what they do and how to use them. But, I would like to use them with more than one file (and without any shell-loop; loading the 'perl' once.) I did try it and -n works on 2 files. Question is: - is it possible to... (6 Replies)
Discussion started by: alex_5161
6 Replies

3. Shell Programming and Scripting

sed command to replace a line in a file using line number from the output of a pipe.

Sed command to replace a line in a file using line number from the output of a pipe. Is it possible to replace a whole line piped from someother command into a file at paritcular line... here is some basic execution flow.. the line number is 412 lineNo=412 Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies

4. UNIX for Dummies Questions & Answers

To find and display the middle line in a file using single line command.

Hi all, How can i display the middle line of a file using a single line command? (6 Replies)
Discussion started by: Lakme Pemmaiah
6 Replies

5. Shell Programming and Scripting

SH script, variable built command fails, but works at command line

I am working with a sh script on a solaris 9 zone (sol 10 host) that grabs information to build the configuration command line. the variables Build64, SSLopt, CONFIGopt, and CC are populated in the script. the script includes CC=`which gcc` CONFIGopt=' --prefix=/ --exec-prefix=/usr... (8 Replies)
Discussion started by: oly_r
8 Replies

6. UNIX for Advanced & Expert Users

unix command : how to insert text at the cursor location via command line?

Hi, Well my title isn't very clear I think. So to understand my goal: I have a script "test1" #!/bin/bash xvkbd -text blabla with xbindkeys, I bind F5 key in order it runs my test1 script So when I press F5, test1 runs. I'm under Emacs/Vi and I press F5 in order to have "blabla" be... (0 Replies)
Discussion started by: xib.be
0 Replies

7. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

8. Shell Programming and Scripting

Is command line invocation of gnome-terminal to run more than one command possible?

Hello, I am trying to learn how to pass something more than a one-command startup for gnome-terminal. I will give an example of what I'm trying to do here: #! /bin/bash # #TODO write this for gnome and xterm USAGE=" ______________________________________________ ${0##*/} run... (0 Replies)
Discussion started by: Narnie
0 Replies

9. Solaris

Inactive Ser Mgt and Net Mgt Ports

Hi, These ports of My T1000 are off. My Serial Management Port used to work. It gave me access to the "sc>" window. Now, i can't see it on my network (with the ZenMap tool) So, i can't power on (or off) my sun T1000. Can someone help me ? Thanks (5 Replies)
Discussion started by: Begbie78
5 Replies

10. Shell Programming and Scripting

assign a command line argument and a unix command to awk variables

Hi , I have a piece of code ...wherein I need to assign the following ... 1) A command line argument to a variable e.g origCount=ARGV 2) A unix command to a variable e.g result=`wc -l testFile.txt` in my awk shell script When I do this : print "origCount" origCount --> I get the... (0 Replies)
Discussion started by: sweta_doshi
0 Replies
Login or Register to Ask a Question