Help in SED and CUT.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in SED and CUT.
# 1  
Old 09-20-2007
Help in SED and CUT.

Hi
I have a file.
In Each and every line, i want to cut the position from 130 to 134 and
need to check if it is XXXX then
i need to replace with YYYY (Only from 130 to 134).


Your help is very much appriciated.
# 2  
Old 09-20-2007
What do you mean by 'position'? Is it the characters from 130 to 134 in one line, or is it lines from 130 to 134?
# 3  
Old 09-20-2007
In each and every line , i want to take characters from 130 to 144.
(cut -c 130-140 <filename> )
# 4  
Old 09-20-2007
130 to 134 make if 5 char's

for 131 to 134....


cat Inp_file|sed 's/^\(.\{130\}\)\(XXXX\)\(.*$\)/\1YYYY\3/g'
# 5  
Old 09-20-2007
Thanks..Its working now.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed should cut seconds

Hi! I need help to modify a comma-sep. file. I tried to cut the secons of a timestamp. ... 11,05/15/12,13:20:00,Raw Counts,58313,5280,6967 13,05/15/12,13:40:00,Raw Counts,70637,6592,8648 ... it should be: 11,05/15/12,13:20,Raw Counts,58313,5280,6967 13,05/15/12,13:40,Raw... (5 Replies)
Discussion started by: IMPe
5 Replies

2. Shell Programming and Scripting

sed cut columns

hello everyone ! i face the following problem as i use sed to ignore some columns of an output. the command i use is sed 's/^\(*\) \(*\).*/\1 \2/' as i only want the 2 first columns the command finger returns the problem is that for some lines the results are fine but for other lines... (8 Replies)
Discussion started by: vlm
8 Replies

3. Shell Programming and Scripting

Substring using cut/awk/sed

Hi Gurus,I have a seemingly simple problem but struggling with it.It is as follows : I/p string - ABCDEFGHIJ20100909.txt desired o/p - AB,DEF,20100909,ABCDEFGHIJ20100909.txt How to achieve it ?Thanks in advance. Please use code tags, thank you (20 Replies)
Discussion started by: sumoka
20 Replies

4. UNIX for Dummies Questions & Answers

How to use cut or sed for my little script.

Hello people, I have a little script that has to compare some files (exe files)... so i find all the files in the given paths (2 paths) and it generates 2 txt files (named 1.txt and 2.txt, they have to be identical) i need to have a little IF function to compare the 2 files and see if they are... (2 Replies)
Discussion started by: valiadi
2 Replies

5. Shell Programming and Scripting

Passing a variable to sed or cut

:confused: Is it possible to send a variable to a sed or cut command? I have a test script as below: counter=1 while read line do # Test the file printf "$line" > temp$counter pref=$(cut c1-2000 $temp$counter | sed 's///g' | sed 's|.*PutTime\(.*)Origin.*|\1|') printf" let... (5 Replies)
Discussion started by: gugs
5 Replies

6. Shell Programming and Scripting

cut in sed/awk

Hi Can i have an example where i should be able to cut columns (like for eg cut -c 1-3) in sed or awk. Regards Dhana (12 Replies)
Discussion started by: dhanamurthy
12 Replies

7. Shell Programming and Scripting

awk,sed or cut problem

Good afternoon, Sir's, I would like to seek your assistance regarding on this matter. $cat file1 111 aaaa bbb aass aaa files file1 temp temp1 pix 222 11 22 1 33 44 desired output: aaaa bbb aass files file1 temp1 222 11 22 1 33 44 thanks (7 Replies)
Discussion started by: invinzin21
7 Replies

8. Shell Programming and Scripting

cut sed grep or other?

Hi Is there a way to cut the last two characters off a word or number given that this word or number can be of varying length? I have tried something like TEST=`echo $OLD | cut -c 1-5` where $OLD is a variable containing a number like 1234567 which gives a result of 12345. This is fine... (4 Replies)
Discussion started by: rleebife
4 Replies

9. Shell Programming and Scripting

SED and Cut question

I am trying to cut and delete using sed and redirect back into the file. This is not working write. When testing the script, it hangs. Any idea what I am doing wrong here. ################ Reads the input file to cut volumes for returns and CUT_ERVTAPE_FILE() { echo "working on cut... (2 Replies)
Discussion started by: gzs553
2 Replies

10. UNIX for Dummies Questions & Answers

cut vs. sed vs. awk ?

hi again...need new help guys:p the file contains following infos... users/abc/bla1.exe newusers/defgh/ik/albg2.exe users2/opww/ertz/qqwertzu/rwerwew.exe how to get the file content into... users/abc/ newusers/defgh/ik/ users2/opww/ertz/qqwertzu/ with... you can erase the... (5 Replies)
Discussion started by: svennie
5 Replies
Login or Register to Ask a Question