using sed with indexes


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers using sed with indexes
# 1  
Old 07-12-2005
using sed with indexes

Hi people,

Is this possible and if so any tips are very welcome.

Im trying to do the following:


this is what I have:
800__1__
this is what I want:
8000010
12345678


Im only interested in postions 1,2,4,5,6,7 and if they have a white space(given a underscore for clarity) replace them with a zero. Take for instance position 8 that has a white space but is not one of the positions I'm interesed in so I want to ignore this position.

this is only a sample of the full size.

any idea how to by this ?

Much appreciated if you do help.
# 2  
Old 07-12-2005
gnu sed:
Code:
sed 'h;s/.......//;x;s/\(.......\).*/\1/;s/ /0/g;G;s/\n//'

 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Adding indexes with PERL

Hello. I'm trying to self learn Perl and am stuck. I have a data.csv file that contains the following: 5,10,15,20,15,30 1,2,3,4,5 3,10 11 I'm trying to get Perl to take the indexes and add them all together to get 134. It says I need to use split and invoke the file via <> (built-in... (2 Replies)
Discussion started by: Eric7giants
2 Replies

2. Shell Programming and Scripting

I need to find out disk usage for particular indexes for different hosts

Need disk utilisation script for particular indexes on few hosts (3 Replies)
Discussion started by: Krish5v
3 Replies

3. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

4. Shell Programming and Scripting

open files with multiple indexes

Hi, I want to work with multiple files which all contain 2 numbers. I tried to make a nested for loop but for some reason it doesn't recognize the $j as a number. The output is cannot open file `175-T-pvalue.xls'. How do I make sure that it takes the numbers from the inner loop as $j? ... (4 Replies)
Discussion started by: linseyr
4 Replies

5. Shell Programming and Scripting

remote/automated OS X folder label indexes triggered from PHP

I have a shell script that updates OS X color label indexes of folders/files as specified in an XML file. This works from terminal, but not when I trigger it from Apache/PHP. The server is not public, so not too worried about security. I've tried to allow access in sudoers, but no dice. I could use... (1 Reply)
Discussion started by: bradlecat
1 Replies

6. Red Hat

[Errno 22] invalid mode ('w') or filename: '//var/lib/yum/rpmdb-indexes/conflicts.tmp'

Can anyone help me with this error? sudo yum install perl-Gtk2-WebKit Loaded plugins: langpacks, presto, refresh-packagekit, versionlock Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package perl-Gtk2-WebKit.i686 0:0.09-1.fc15 will be installed -->... (0 Replies)
Discussion started by: cokedude
0 Replies

7. Shell Programming and Scripting

matrix indexes

I wanted to use matrixs in awk and got some problem, here is some of the script code, from the BEGIN tag: row_char="a";row_char="b";row_char="c";row_char="d";row_char="e"$ row_char="h";row_char="i";row_char="j";row_char="k"; from the proccess passage: sentence,1]=1; diffrence=4; i=7;... (2 Replies)
Discussion started by: tal
2 Replies

8. Shell Programming and Scripting

Analyze the indexes and rebuild them

Hello UNIX and Oracle Gurus, After doing an intensive search from different websites, the UNIX forum I am posting this message seeking help.. I am trying to accomplish the following tasks through the shell script: 1. Rebuild indexes on a Table in Oracle 2. Analyze indexes and table... (0 Replies)
Discussion started by: madhunk
0 Replies
Login or Register to Ask a Question