String manipulation in Linux & Unix (Solaris)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers String manipulation in Linux & Unix (Solaris)
# 1  
Old 09-10-2009
String manipulation in Linux & Unix (Solaris)

Guy

I have this below report and I need someone help me formatting it

Code:
SID      File Name         Started                     Finished                Backup
ABC      XYZ.log           10Sep09-012857\n      10Sep09-020748    Successful

I need Started & Finished columns to be formatted as

Code:
10Sep09 01:28:57  & 10Sep09 02:07:48

I dont know why I am getting \n at the end of Started column

How to leave a single in Linux (as with solaris we use \n)?

Last edited by Franklin52; 09-10-2009 at 11:19 AM.. Reason: Please use code tags!
# 2  
Old 09-10-2009
Hi Suri,
i tested this code which is working fine and let us know if you want this out put.
code:

Code:
cat file_name|sed '1,$s/\\n//g
s/-/ /g'|awk '{print $1,$2,$3,substr($4,1,2)":"substr($4,3,2)":"substr($4,5,2)" &",$5,substr($6,1,2)":"substr($6,3,2)":"substr($6,5,2),$7}'

ABC XYZ.log 10Sep09 01:28:57  & 10Sep09 02:07:48 Successful

Regards,
Sanjay

Last edited by Franklin52; 09-10-2009 at 04:07 PM.. Reason: Please use code tags!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

LINUX - How to replace a string & its current value with a new value

Hi All, i am trying to replace a string & its current value (P_JOBID =1000 for eg) in a file with a new value(P_JOBID =2000) through sed command. File name : A.txt Command I am trying : `cat $path/A.txt | grep ${P_JOBID} | sed -e s/P_JOBID=/P_JOBID="$JobID"/g` Output Expected :... (5 Replies)
Discussion started by: dsfreddie
5 Replies

2. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

3. UNIX and Linux Applications

Solaris & Linux memory stress test?

I'm looking for a script or some other application that will use up a lot of memory on a Solaris or Linux server, in order to test a monitoring application. So far I have found a script that's good for CPU usage but it does nothing for memory. I have also tried the application called 'stress'... (0 Replies)
Discussion started by: Kraas
0 Replies

4. Shell Programming and Scripting

how to compare string & integer in unix

Hi All, i am doung sup up of amount column in my file. tot_val=`awk '{a+=$0}END{printf "%.5f\n",a}' amount` then i have a checksum in footer. chk_sum=`tail -1 $FILE_NAME | cut -d~ -f7 | cut -c2-` but the problem is while executing 1st command i am getting : 27720.75000 & while... (3 Replies)
Discussion started by: Amit.Sagpariya
3 Replies

5. Linux

string manipulation in unix

Hi, I have a question . I have script which gets info from db2 engine. The script is cat sample_substitute.sh CNTR_NM=`db2 -x "select CONTAINER_NAME ,usable_pages from table( SNAPSHOT_CONTAINER('TST103',-1)) as SNAPSHOT_CONTAINER, syscat.tablespaces where tablespace_name = tbspace and... (3 Replies)
Discussion started by: capri_drm
3 Replies

6. Linux

Linux 7.3 & Sun Solaris 8 - common account login

is it possible to have an common login account for both linux and Solaris? Having problem in logging into linux, unable to load completely. home directory residue in Solaris 8, export out. No NIS running, only NFS in place. (6 Replies)
Discussion started by: jennifer
6 Replies

7. UNIX for Dummies Questions & Answers

Learning Unix & Linux

I'm new to Unix. I'm just looking for really good unix documents through Internet as pdf format on programming in all shells, and system adminstrator documents, and well as just all around really good documents on unix. Thank you (5 Replies)
Discussion started by: faaarin
5 Replies

8. UNIX Desktop Questions & Answers

what is the difference between Unix & linux, what are the advantages & disadvantages

ehe may i know what are the difference between Unix & Linux, and what are the advantages of having Unix as well as disadvantages of having Unix or if u dun mind i am dumb do pls tell me what are the advantages as well as the disadvantages of having linux as well. thanks (1 Reply)
Discussion started by: cybertechmkteo
1 Replies

9. UNIX for Dummies Questions & Answers

Are Unix & Linux the Same ?

Well i have downloaded some Linux stuff and isos but before i install i really like to know what is the diffirence and i like to install apache webserver , can it be done on Linux ? I am a real Dummy but after some practice i will be a PRO :-) Thanks for all the replies .. (1 Reply)
Discussion started by: zodiac
1 Replies
Login or Register to Ask a Question