Sponsored Content
Full Discussion: "sed" ignoring last line
Top Forums Shell Programming and Scripting "sed" ignoring last line Post 302743729 by darling on Thursday 13th of December 2012 07:23:07 AM
Old 12-13-2012
"sed" ignoring last line

Hi,

I am giving below command script and getting below output. I tried using "sed" which is ignoring 4th line. Can you please help me to get the expected output like below
Code:
Code:
echo "dis clusqmgr(*) cluster(BT.CL.OFSSTAT4) conname qmtype deftype"| runmqsc -e $QMGR|egrep 'CHANNEL|QMTYPE|CLUSQMGR|CONNAME|DEFTYPE'|sed -e 's/CLUSQMGR(/+/g'|sed -e 's/CLUSQMGR(/+/g'|tr -d "\n"|tr "+" "\n"

Getting Output:

Please note QMTYPE(REPOS) is coming down and then again SU* is coming in next line
Code:
SU.QM.EMB70xtx)                CHANNEL(OFSSTAT4.EMB70xtx.Cx)   CLUSTER(SU.CL.OFSSTAT4)                 CONNAME(x0.N9.70.x0(Tx43x))   DEFTYPE(CLUSSDRA) 
QMTYPE(REPOS)
SU.QM.EMB70xtN)                CHANNEL(OFSSTAT4.EMB70xtN.Cx)   CLUSTER(SU.CL.OFSSTAT4)                 CONNAME(x0.N9.70.xx(Tx43N))   DEFTYPE(CLUSSDRB)
 QMTYPE(REPOS)
SU.QM.OFSMMxTx)                CHANNEL(OFSSTAT4.OFSMMxTx.Cx)   CLUSTER(SU.CL.OFSSTAT4)                 CONNAME(x0.x88.T8.9x(Tx43x))   DEFTYPE(CLUSSDRA)
 QMTYPE(NORMAL)
SU.QM.OFSMMxTN)                CHANNEL(OFSSTAT4.OFSMMxTN.Cx)   CLUSTER(SU.CL.OFSSTAT4)                 CONNAME(x0.x88.T8.94(Tx43N))   DEFTYPE(CLUSRCVR)                       
QMTYPE(NORMAL)

Expecting output:

Code:
SU.QM.EMB70xtx,                 OFSSTAT4.EMB70xtx.Cx,    SU.CL.OFSSTAT4,                  x0.N9.70.x0,Tx43x,    CLUSSDRA,                        REPOS,
SU.QM.EMB70xtN,                 OFSSTAT4.EMB70xtN.Cx,    SU.CL.OFSSTAT4,                  x0.N9.70.xx,Tx43N,    CLUSSDRB,                        REPOS,
SU.QM.OFSMMxTx,                 OFSSTAT4.OFSMMxTx.Cx,    SU.CL.OFSSTAT4,                  x0.x88.T8.9x,Tx43x,    CLUSSDRA,                        NORMAL,
SU.QM.OFSMMxTN,                 OFSSTAT4.OFSMMxTN.Cx,    SU.CL.OFSSTAT4,                  x0.x88.T8.94,Tx43N,    CLUSRCVR,                        NORMAL,


Last edited by Scrutinizer; 12-13-2012 at 08:28 AM.. Reason: quote tags -> code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

"read" command ignoring leading spaces

I have to read a file line by line, change it and then update the file. Problem is, when i read the file, "read" command ignores leading spaces. The file is a script which is indented in many places for clarity. How to i make "read" command read leading spaces as well. (3 Replies)
Discussion started by: vickylife
3 Replies

3. Shell Programming and Scripting

SED or AWK "append line to the previous line"

Hi, How can I remove the line beak in the following case if the line begin with the special char “;”? TEXT Text;text ;text Text;text;text I want to convert the text to: Text;text;text Text;text;text I have already tried to use... (31 Replies)
Discussion started by: research3
31 Replies

4. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

7. Shell Programming and Scripting

Is it possible to use sed to handle the line contains BOTH "AA" and "BB"

if yes, can some expert give an example Lei (2 Replies)
Discussion started by: yanglei_fage
2 Replies

8. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

9. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

10. Shell Programming and Scripting

Failure: if grep "$Var" "$line" inside while read line loop

Hi everybody, I am new at Unix/Bourne shell scripting and with my youngest experiences, I will not become very old with it :o My code: #!/bin/sh set -e set -u export IFS= optl="Optl" LOCSTORCLI="/opt/lsi/storcli/storcli" ($LOCSTORCLI /c0 /vall show | grep RAID | cut -d " "... (5 Replies)
Discussion started by: Subsonic66
5 Replies
CLUSTER(7)							   SQL Commands 							CLUSTER(7)

NAME
CLUSTER - cluster a table according to an index SYNOPSIS
CLUSTER [VERBOSE] tablename [ USING indexname ] CLUSTER [VERBOSE] DESCRIPTION
CLUSTER instructs PostgreSQL to cluster the table specified by tablename based on the index specified by indexname. The index must already have been defined on tablename. When a table is clustered, it is physically reordered based on the index information. Clustering is a one-time operation: when the table is subsequently updated, the changes are not clustered. That is, no attempt is made to store new or updated rows according to their index order. (If one wishes, one can periodically recluster by issuing the command again. Also, setting the table's FILLFACTOR storage parameter to less than 100% can aid in preserving cluster ordering during updates, since updated rows are preferentially kept on the same page.) When a table is clustered, PostgreSQL remembers which index it was clustered by. The form CLUSTER tablename reclusters the table using the same index as before. CLUSTER without any parameter reclusters all the previously-clustered tables in the current database that the calling user owns, or all such tables if called by a superuser. This form of CLUSTER cannot be executed inside a transaction block. When a table is being clustered, an ACCESS EXCLUSIVE lock is acquired on it. This prevents any other database operations (both reads and writes) from operating on the table until the CLUSTER is finished. PARAMETERS
tablename The name (possibly schema-qualified) of a table. indexname The name of an index. VERBOSE Prints a progress report as each table is clustered. NOTES
In cases where you are accessing single rows randomly within a table, the actual order of the data in the table is unimportant. However, if you tend to access some data more than others, and there is an index that groups them together, you will benefit from using CLUSTER. If you are requesting a range of indexed values from a table, or a single indexed value that has multiple rows that match, CLUSTER will help because once the index identifies the table page for the first row that matches, all other rows that match are probably already on the same table page, and so you save disk accesses and speed up the query. During the cluster operation, a temporary copy of the table is created that contains the table data in the index order. Temporary copies of each index on the table are created as well. Therefore, you need free space on disk at least equal to the sum of the table size and the index sizes. Because CLUSTER remembers the clustering information, one can cluster the tables one wants clustered manually the first time, and setup a timed event similar to VACUUM so that the tables are periodically reclustered. Because the planner records statistics about the ordering of tables, it is advisable to run ANALYZE [analyze(7)] on the newly clustered ta- ble. Otherwise, the planner might make poor choices of query plans. There is another way to cluster data. The CLUSTER command reorders the original table by scanning it using the index you specify. This can be slow on large tables because the rows are fetched from the table in index order, and if the table is disordered, the entries are on ran- dom pages, so there is one disk page retrieved for every row moved. (PostgreSQL has a cache, but the majority of a big table will not fit in the cache.) The other way to cluster a table is to use: CREATE TABLE newtable AS SELECT * FROM table ORDER BY columnlist; which uses the PostgreSQL sorting code to produce the desired order; this is usually much faster than an index scan for disordered data. Then you drop the old table, use ALTER TABLE ... RENAME to rename newtable to the old name, and recreate the table's indexes. The big dis- advantage of this approach is that it does not preserve OIDs, constraints, foreign key relationships, granted privileges, and other ancil- lary properties of the table -- all such items must be manually recreated. Another disadvantage is that this way requires a sort temporary file about the same size as the table itself, so peak disk usage is about three times the table size instead of twice the table size. EXAMPLES
Cluster the table employees on the basis of its index employees_ind: CLUSTER employees USING employees_ind; Cluster the employees table using the same index that was used before: CLUSTER employees; Cluster all tables in the database that have previously been clustered: CLUSTER; COMPATIBILITY
There is no CLUSTER statement in the SQL standard. The syntax CLUSTER indexname ON tablename is also supported for compatibility with pre-8.3 PostgreSQL versions. SEE ALSO
clusterdb [clusterdb(1)] SQL - Language Statements 2010-05-14 CLUSTER(7)
All times are GMT -4. The time now is 09:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy