I tried with sed and awk but not getting in required format.  1.1.0010.1214.10   Expected output:  1.1.0010.121410   I tried below ways  echo "1.1.0010.1214.10" | sed -e "s/\(.*\)./\1/g" 1.1.0010.1214.1
122490
How do I replace only the last occurrence of "-" in a string with a space using sed?  For example:  echo $MASTER_DISK_RELEASE swp-RedHat-Linux-OS-5.5.0.0-03   but I want to get the following output ( replacing the last hyphen [“-“] with a space )  swp-RedHat-Linux-OS-5.5.0.0 03
5286
I have a script that reads a text stream and generates a file of sed commands that is later run with sed -f. The generated sed commands are like:  s/cid:image002\.gif@01CC3D46\.926E77E0/https:\/\/mysite.com\/files\/1922/g s/cid:image003\.gif@01CC3D46\.926E77E0/https:\/\/mysite.com\/files\/1923/g s/cid:image004\.jpg@01CC3D46\.926E77E0/https:\/\/mysite.com\/files\/1924/g   Assume the script which generates the sed commands is something like:  while read cid fileid do     cidpat="$(echo $cid | sed -e s/\\./\\\\./g)"     echo 's/'"$cidpat"'/https:\/\/mysite.com\/files\/'"$fileid"'/g' &gt;&gt; sedscr done   How can I improve the script to ensure all regex metacharacters in the cid string are escaped and interpolated properly?
80918
Input data after sorting by Column 1  -bash-3.2$ sort -t'|' -k1  -k2 clm.srt "1033CLMS0400000000000"||""|"0000000558             "|     |1 "2020000005438WC011631"||""|"              200606202"|     |2 "2020000005438WC011632"|10|"N"|"20060626N00000200000"|10   |3 "2020000005438WC011632"|11|"N"|"20060626N00000200000"|11   |4 "2020000005438WC011632"|12|"N"|"20060626N00000200000"|12   |5 "2020000005438WC011632"|1|"N"|"20060620N000020000000"|1    |13 "2020000005438WC011632"|47|"N"|"20060626N00000000000"|47   |43 "2020000005438WC011632"|5|"N"|"20060626N000000000000"|5    |45 "2020000005438WC011632"|6|"N"|"20060626N0002N0200000"|6    |46 "2020000005438WC011632"|7|"N"|"20060626N000002N00000"|7    |47 "2020000005438WC011632"|8|"N"|"20060626N000000200000"|8    |48 "2020000005438WC011632"|9|"N"|"20060626N0000N0200000"|9    |49 "2020000005438WC011633"||""|"20060605000            "|     |50 "2020000005438WC011634"||""|"001033720061           "|     |51 "2020000005438WC011635"||""|"0020060626N+00014000000"|     |52   If I force numeric sort on 2nd field, blank values are pushed to top, this disturbs my first field sort  -bash-3.2$ sort -t'|' -k1 -n -k2 clm.srt "1033CLMS0400000000000"||""|"0000000558             "|     |1 "2020000005438WC011631"||""|"              200606202"|     |2 "2020000005438WC011633"||""|"20060605000            "|     |50 "2020000005438WC011634"||""|"001033720061           "|     |51 "2020000005438WC011635"||""|"0020060626N+00014000000"|     |52 "2020000005438WC011632"|1|"N"|"20060620N000020000000"|1    |13 "2020000005438WC011632"|5|"N"|"20060626N000000000000"|5    |45 "2020000005438WC011632"|6|"N"|"20060626N0002N0200000"|6    |46 "2020000005438WC011632"|7|"N"|"20060626N000002N00000"|7    |47 "2020000005438WC011632"|8|"N"|"20060626N000000200000"|8    |48 "2020000005438WC011632"|9|"N"|"20060626N0000N0200000"|9    |49 "2020000005438WC011632"|10|"N"|"20060626N00000200000"|10   |3 "2020000005438WC011632"|11|"N"|"20060626N00000200000"|11   |4 "2020000005438WC011632"|12|"N"|"20060626N00000200000"|12   |5 "2020000005438WC011632"|47|"N"|"20060626N00000000000"|47   |43   Ideally I was trying to acheive this  "1033CLMS0400000000000"||""|"0000000558             "|     |1 "2020000005438WC011631"||""|"              200606202"|     |2 "2020000005438WC011632"|1|"N"|"20060620N000020000000"|1    |13 "2020000005438WC011632"|5|"N"|"20060626N000000000000"|5    |45 "2020000005438WC011632"|6|"N"|"20060626N0002N0200000"|6    |46 "2020000005438WC011632"|7|"N"|"20060626N000002N00000"|7    |47 "2020000005438WC011632"|8|"N"|"20060626N000000200000"|8    |48 "2020000005438WC011632"|9|"N"|"20060626N0000N0200000"|9    |49 "2020000005438WC011632"|10|"N"|"20060626N00000200000"|10   |3 "2020000005438WC011632"|11|"N"|"20060626N00000200000"|11   |4 "2020000005438WC011632"|12|"N"|"20060626N00000200000"|12   |5 "2020000005438WC011632"|47|"N"|"20060626N00000000000"|47   |43 "2020000005438WC011633"||""|"20060605000            "|     |50 "2020000005438WC011634"||""|"001033720061           "|     |51 "2020000005438WC011635"||""|"0020060626N+00014000000"|     |52
61269
Is there a way to modify a file without writing the contents to another file, without sed and awk?  For example:  $ cat test.txt aaa aaa bbb ccc ddd   Replacing using sed with -i option, sed -i 's/aaa/NNN/g' test.txt will produce the following:  NNN NNN bbb ccc ddd   How to do that without awk and sed?
73123
there is a script I evolved with it, it has line of command like below :  mytemp=`echo ${sourcedir}|awk -F/ '{printf "/%s/tmp",$2}'`/`basename $0`-$1.$$   at the last of the command we see $$ that produces a number. when I use echo $$ in bash I also see a number like bellow:   #echo $$  23019   what exactly is this number, and what is $$?
54965
My script:  date echo -e "${YELLOW}Network check${NC}\n\n"  while read hostname do  ping -c 1 "$hostname" &gt; /dev/null 2&gt;&amp;1 &amp;&amp;  echo -e "Network $hostname : ${GREEN}Online${NC}" || echo -e "${GRAY}Network $hostname${NC} : ${RED}Offline${NC}"  done &lt; list.txt         sleep 30 clear done   Is outputting info like this:    Network 10.x.xx.xxx : Online    Network 10.x.xx.xxx : Offline    Network 10.x.xx.xxx : Offline    Network 10.x.xx.xxx : Offline    Network 10.x.xx.x : Online    Network 139.xxx.x.x : Online    Network 208.xx.xxx.xxx : Online    Network 193.xxx.xxx.x : Online   which I'd like to clean up to get something like this:    Network 10.x.xx.xxx       : Online   Network 10.x.xx.xxx       : Offline    Network 10.x.xx.xxx       : Offline     Network 10.x.xx.x         : Online     Network 139.xxx.x.x       : Online   Network 208.xx.xxx.xxx    : Online     Network 193.xxx.xxx.x     : Online   Network 193.xxx.xxx.xxx   : Offline
109159
I have a file with the following contents:  select *  from  emp;   select *  from  dept;  selection end;   I want to obtain this output:  select *  from  emp;   select *  from  dept;   I tried by using   awk '/SELECT/{a=1} a; /;/{a=0}' XXARXADLMT.txt    But it didn't work.
80748
I have a file like this: 1 22 1 4 $3 3 5556 $33 $233 $1 5  I want to move all the lines starting with $ to the previous line by replacing the newline characters with a space. My result should look something like: 1 22 1 4 $3 3 5556 $33 $233 $1 5  How can I do it using sed or grep or awk?
58966
I have a file that has below entries:  [root@ovmm329 ovm_utils]# cat /tmp/disk.txt Physical Disk : 'IBM (67) device=/dev/mapper/360050768018206483000000000000453 shareddisk=true Physical Disk : 'IBM (58) device=/dev/mapper/36005076801820648300000000000043f shareddisk=true Physical Disk : 'IBM (59) device=/dev/mapper/360050768018206483000000000000440 shareddisk=true Physical Disk : 'IBM (71) device=/dev/mapper/360050768018206483000000000000497 shareddisk=true [root@ovmm329 ovm_utils]#   I tried using sed and awk in all possible way which I am aware of but couldn't get it in the required format. I would like to have the file in this format:  Physical Disk  device                                          Shareddisk IBM (67)        /dev/mapper/360050768018206483000000000000453  true IBM (58)        /dev/mapper/36005076801820648300000000000043f  true IBM (59)        /dev/mapper/360050768018206483000000000000440  true IBM (71)        /dev/mapper/360050768018206483000000000000497  true
108168
In this line:  Reply from 10.11.12.13 time=1035ms   how to write an awk script which brings out just 1035.
96240
Suppose to have a file .dat like this:   -4.8767000e+000 -2.9142000e-001             NaN             NaN             NaN             NaN  -3.9017000e+000 -4.1404000e-001             NaN             NaN             NaN             NaN  -3.7141000e+000             NaN             NaN -2.6865000e-001             NaN             NaN  -2.8267000e+000 -8.5233000e-001             NaN             NaN             NaN             NaN  -2.7641000e+000             NaN -3.0872000e-001             NaN             NaN             NaN  -2.5488000e+000             NaN             NaN -4.1579000e-001             NaN             NaN  -1.9125000e+000             NaN             NaN             NaN             NaN -1.3021000e-001  -1.8869000e+000             NaN             NaN             NaN -2.4675000e-001             NaN  -1.7165000e+000             NaN -5.1881000e-001             NaN             NaN             NaN  -1.6755000e+000 -1.6062000e+000             NaN             NaN             NaN             NaN  -1.4064000e+000             NaN             NaN -6.1630000e-001             NaN             NaN  -8.3837000e-001             NaN             NaN             NaN -5.1510000e-001             NaN  -7.9259000e-001             NaN             NaN             NaN             NaN -4.0836000e-001  -6.4542000e-001 -2.2095000e+000             NaN             NaN             NaN             NaN  -5.4987000e-001             NaN -7.4848000e-001             NaN             NaN             NaN  -4.2297000e-001             NaN             NaN -1.2681000e+000             NaN             NaN   2.0480000e-001             NaN -1.9436000e+000             NaN             NaN             NaN   2.1333000e-001             NaN             NaN             NaN -9.8248000e-001             NaN   3.3584000e-001             NaN             NaN             NaN             NaN -1.2254000e+000   4.4876000e-001 -2.3614000e+000             NaN             NaN             NaN             NaN   7.7282000e-001             NaN             NaN -1.8424000e+000             NaN             NaN   1.3886000e+000             NaN             NaN             NaN -1.7607000e+000             NaN   1.4709000e+000             NaN -2.4598000e+000             NaN             NaN             NaN   1.5644000e+000 -2.3726000e+000             NaN             NaN             NaN             NaN   1.8937000e+000             NaN             NaN -2.1788000e+000             NaN             NaN   2.3417000e+000             NaN             NaN             NaN -1.9949000e+000             NaN   2.4386000e+000             NaN             NaN             NaN             NaN -2.1213000e+000   2.5903000e+000             NaN -2.7040000e+000             NaN             NaN             NaN   2.9174000e+000             NaN             NaN -2.3792000e+000             NaN             NaN   3.4874000e+000             NaN             NaN             NaN -2.4042000e+000             NaN   3.5796000e+000             NaN             NaN             NaN             NaN -2.2296000e+000   3.7549000e+000             NaN -2.8123000e+000             NaN             NaN             NaN   3.9405000e+000             NaN             NaN -2.5407000e+000             NaN             NaN   4.6521000e+000             NaN             NaN             NaN -2.5125000e+000             NaN   If I plot thse data with the following minimal code:  \documentclass{report}  \usepackage[showframe,             margin=2.5cm,             left=3cm]{geometry}  \usepackage{pgfplots} \pgfplotsset{compat=1.4}  \begin{document} \centering \begin{tikzpicture} \begin{axis}  \foreach \n in {1,2,...,5}{ \addplot table[x index = 0,                y index = \n]{DATA.dat}; } \end{axis} \end{tikzpicture} \end{document}   PGFplots skip the first row. It means that the y points in the first row are not plotted!!  Is it because PGFplots see it like a row with column names?  Is it possible to solve this problem?
69314
I have several big files with some measurements.   It looks this way:  N 12344;PE 9.9999999;... #S 0 0 31 44 75 130 165 196... #S_+ "2 5 2 3 3 1 1 2 3 1 2 2...  N 12345;PE 9.9999999;... #S 0 0 34 57 84 133 152... #S_+ "1 0 1 1 2 3 0 0 0...  N 12346;PE 9.9999999;... #S 0 0 31 44 73 140 169... #S_+ "3 3 4 0 0 2 1 2 4...  N 25104;PE 9.9999999;... #S 0 0 36 52 102 108 145... #S_+ "1 1 0 1 0 0 3 0 1...  N 25105;PE 9.9999999;... #S 0 0 32 58 88 130 143...   Sample is here:   The file is much bigger but I replaced part of the data with "..." to make it shorter.  I need to somehow replace the line ends before "#S" - in fact simply merge the "N" line with the following two ones into one line (or with the following three ones so I can get rid of the blank lines). Expect output like this:  N 12344;PE 9.9999999; #S 0 0 31 44 75 130 165 196 #S_+ "2 5 2 3 3 1 1 2 3 1 2 2... N 12345;PE 9.9999999; #S 0 0 34 57 84 133 152 #S_+ "1 0 1 1 2 3 0 0 0... N 12346;PE 9.9999999; #S 0 0 31 44 73 140 169 #S_+ "3 3 4 0 0 2 1 2 4... N 25104;PE 9.9999999; #S 0 0 36 52 102 108 145 #S_+ "1 1 0 1 0 0 3 0 1... N 25105;PE 9.9999999; #S 0 0 32 58 88 130 143...   Is this possible to achieve using some command-line utility in linux?   My knowledge is quite limited in this area so I would appreciate any help.  thanks
65206
Imagine an output of a command like  44444 55555 11111 22222 33333   how can I yank the first N lines (first two in the example above) and append them at the end, but without using temp file (so only using pipes)?  11111 22222 33333 44444 55555   Something along the lines of | sed -n '3,5p;1,2p' (which obviously doesn't work as sed doesn't care about the order of the commands).
119154
#!/bin/bash ping -c 1 8.8.8.8 | awk '{print $7}' date   So for the code above, I want it to display the date and time in this format below  Tue May 5 11:11:11 UTC 2020  time=0.838 ms   So far it prints this output  data. time=1.24 packet Tue May  5 23:31:33 UTC 2020   I want time=1.24 next to the UTC 2020
122795
I have a requirement like i have to remove the strings or numbers between two Parenthesis in a file. I used sed command but it is working on a single line. My opening Parenthesis is in one line and the closing parenthesis is in other line. How can i do it?  I tried this command using sed:  sed -e 's/([^()]*)//g'   but this works only when My opening and closing parenthesis are on the same line.  For Example:-  Input file:  select a ,b ,c FROM ABCD (select e ,f ,g ,h FROM XYZ)   Output should be:  select a ,b ,c FROM ABCD
37242
Is it possible to do a multiline pattern match using sed, awk or grep? Take for example, I would like to get all the lines between { and }  So it should be able to match    1. {}  2. {.....}  3. {.....      .....}  Initially the question used &lt;p&gt; as an example. Edited the question to use { and}.
45764
I have a directory full of XML files that look like this, for which I want to change the value of the "offset" element number from 1 to some other number  $ cat my.xml       &lt;offset xmlns=""&gt;1&lt;/offset&gt;   I wrote various combinations of this sed command, but nothing I tried runs without an error.  I am pretty sure that I need to escape some of the characters, but those that I've tried always end in errors ("unexpected token", "unknown option", etc).  I also tried without the -e flag, since it really isn't an expression.  sed -i -e s/&lt;offset xmlns=""&gt;1&lt;/offset&gt;/&lt;offset xmlns=""&gt;99&lt;/offset&gt;/ *.xml   Any help would be appreciated.