|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with shell scripting
Shell Scripting i want to delete bottom line and put in to upper line if it have specific word. ex Code:
Dell 14 20 31 Hp 16 19 Logi 29 89 HP 21 30 Iph 15 60 59 Hp 20 21 22 Output: Code:
Dell 14 20 31 16 19 Logi 29 89 21 30 Iph 15 60 59 20 21 22 Thanks in Advance......... Last edited by Scott; 02-08-2012 at 02:31 PM.. Reason: Code tags |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
Try this... Code:
sed -n 'H; $ {x;s/\n[Hh][Pp]//g;p}' infile--ahamed |
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
Thanks a lot Ahmamed .. But can you help on this.... i have same thing but little bit complex.. file1.txt have below input Code:
6120.log:$_port_info = 001200/port_2_dev_16 6120.log:$_port_info = 001200/port_6_dev_17 6120.log:$_port_info = 001200/port_10_dev_18 6120.log:$_port_info = 001200/port_8_dev_7 6120.log:$_port_info = 001200/port_0_dev_5 6120.log:$_port_info = 001200/port_4_dev_6 6120.log:001200/port_2_dev_16 6120.log:vswr: -0.7[dB] 6120.log:001200/port_6_dev_17 6120.log:vswr: 0.0[dB] 6120.log:001200/port_10_dev_18 6120.log:vswr: -0.7[dB] 6120.log:001200/port_8_dev_7 6120.log:vswr: 17.3[dB] 6120.log:001200/port_0_dev_5 6120.log:vswr: 21.9[dB] 6120.log:001200/port_4_dev_6 6120.log:vswr: 19.5[dB] i need out put like this file2 I want to remove all .log and [db] from all line also remove all unnecessary string and give me output like below...... Code:
6120 122 NoVSWR 6120 126 NoVSWR 6120 1210 NoVSWR 6120 128 NoVSWR 6120 120 NoVSWR 6120 124 NoVSWR 6120 122 -0.7 6120 126 0.0 6120 1210 -0.7 6120 128 17.3 6120 120 21.9 6120 124 19.5 Please help me with this .....again thanks a lottttttttttt Last edited by Scott; 02-08-2012 at 02:30 PM.. Reason: Please use code tags |
|
#4
|
||||
|
||||
|
Where is the second column data coming from? 122, 120 etc
--ahamed |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Ahamed Code:
6120.log:$_port_info = 001200/port_2_dev_16 it will remove all unnecessary string 001200/port_2_dev_16 but i need 12 and 2 with is after port_. Code:
6120.log:$_port_info = 001200/port_2_dev_16 = 6120 122 001200=12 and /port_2 =2 so combine it 122 Thanks for your quick replay brother... ---------- Post updated at 02:14 PM ---------- Previous update was at 12:46 PM ---------- any help please ........................... Last edited by Scott; 02-08-2012 at 02:31 PM.. Reason: Code tags |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Code:
awk -F[:/_=] '{end="NoVSWR";sub(/.log/,"");num=$1;gsub(/[0 ]/,"",$(NF-4));port=$(NF-4)$(NF-2)}
$2!="$"{getline;end=$NF+0}{print num,port,end}' infile--ahamed |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Hi I am getting below error when i run it.... my Script is below... Code:
egrep -e '_dev|vswr:' *.log > $VSWR
awk -F[:/_=] '{end="NoVSWR";sub(/.log/,"");num=$1;gsub(/[0 ]/,"",$(NF-4));port=$(NF-4)$(NF-2)}$2!="$"{getline;end=$NF+0}{print num,port,end}' $VSWRLast edited by Franklin52; 02-09-2012 at 03:18 AM.. Reason: Please use code tags for code and data samples, thank you |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl scripting or shell scripting? | Anna Hussie | Web Programming | 1 | 04-20-2011 04:08 AM |
| Shell Scripting vs Perl scripting | Pouchie1 | What's on Your Mind? | 2 | 02-10-2011 12:21 PM |
| Shell scripting vs Perl scripting | Pouchie1 | What's on Your Mind? | 14 | 09-06-2010 09:48 PM |
| Call Shell scripting from Perl Scripting. | anupdas | Shell Programming and Scripting | 2 | 02-12-2010 07:07 AM |
| difference between AIX shell scripting and Unix shell scripting. | haroonec | Shell Programming and Scripting | 2 | 04-12-2006 08:12 AM |
|
|