Delete part of a column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Delete part of a column
# 1  
Old 09-09-2015
Delete part of a column

I want to delete a part of the 4th column from the given file below:

Code:
<Text Text_ID="10155645315851111_10155645333076543" From="460350337461111" Created="2011-03-16T17:05:37+0000" use_count="123">This is the first text</Text>
<Text Text_ID="10155645315851111_10155645317023456" From="1626711840902323" Created="2011-03-16T17:01:02+0000" use_count="234">This is the second text</Text>
<Text Text_ID="10155645315851111_10155645320006543" From="1481727095384343" Created="2011-03-16T17:02:04+0000" use_count="3456">This is the third text 
If counted  
GOT IT... ����</Text>
<Text Text_ID="10155645315851111_10155645326223345" From="411021195696329" Created="2011-04-16T17:03:44+0000" use_count="5433">This is is just a sample text.......</Text>
<Text Text_ID="10155645315851111_10155645326223445" From="411021195692389" Created="2011-04-16T17:03:44+0000" use_count="5433">This is just another sample text........</Text>
<Text Text_ID="10155645315851111_10155645326222345" From="411021195696789" Created="2011-04-16T17:03:44+0000" like_count="5433">This is the fourth text........</Text>

The part of the column to be deleted is the "use_count="xxxx"> or like_count="xxxx">. However, number of the digits xxxx may be variable. For example, it may be only one digit (x) or two (xx) digits or three (xxx) digits of four (xxx) digits.

I need help to write a script to delete this part.


Thanks in advance. Smilie

Last edited by my_Perl; 09-09-2015 at 07:01 PM.. Reason: Editing
# 2  
Old 09-09-2015
What have you tried?

What operating system are you using?

What shell are you using?
# 3  
Old 09-09-2015
I am missing something...
There is no use_code="xxxx"> but use_count="xxxx"> instead.
I assume this is a typo, if so take care as it throws the rest of us...
What have you tried so far?
How big is the file size likely to be?
What is your shell and the OS in use?
Also take note that you have binary in the file too. These are probably UNICODE characters but show up as unkown question marks on this machine.
(OSX 10.7.5, default bash terminal.)

Last edited by wisecracker; 09-09-2015 at 05:02 PM.. Reason: Added the take note part...
This User Gave Thanks to wisecracker For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To Delete the duplicates using Part of File Name

I am using the below script to delete duplicate files but it is not working for directories with more than 10k files "Argument is too long" is getting for ls -t. Tried to replace ls -t with find . -type f \( -iname "*.xml" \) -printf '%T@ %p\n' | sort -rg | sed -r 's/* //' | awk... (8 Replies)
Discussion started by: gold2k8
8 Replies

2. Shell Programming and Scripting

Find and delete part of field with awk or sed

I've got a file that looks like this (the whitespace between commas is intentional): 123456789,12,JOHN H DOE ,DOE/JOHN H ,,,DOE/JOHN H ,,,,,123 FAKE STREET ,SPRINGFIELD,XX, I want to strip just the first name out of the third field so it reads "JOHN,". So far I... (6 Replies)
Discussion started by: Scottie1954
6 Replies

3. Shell Programming and Scripting

Awk: Need help replacing a specific column in a file by part of a column in another file

Hi, I have two input files as File1 : ABC:client1:project1 XYZ:client2-aa:project2 DEF:client4:proj File2 : client1:W-170:xx client2-aa:WT-04:yy client4:L-005A:zz Also, array of valid values can be hardcoded like Output : ABC:W:project1 XYZ:WT:project2 (1 Reply)
Discussion started by: aa2601
1 Replies

4. Shell Programming and Scripting

Delete Last part

Hello, I am on solaris (ksh). I have a log file like this with directory structure and file name : /DIR1/DIR2/DIR3/filename /DIR1/DIR2/filename /DIR1/DIR2/DIR3/DIR4/DIR5/filename I am looking for a way to create a new file to be formated like this : DIR2/DIR3 DIR2... (9 Replies)
Discussion started by: Aswex
9 Replies

5. Shell Programming and Scripting

delete only part of a line

Hi, I've a file as below- I need to delete only the part of the line after the pattern 'extent /lock' and my output has to be like below. Thanks (7 Replies)
Discussion started by: dvah
7 Replies

6. Shell Programming and Scripting

delete part of file from pattern1 to pattern2

Hi all! How can I delete all the text starting from <string1> to <string2> in all the .txt files of the folder "FOLDER" ? Thanks a lot! mjomba ... </s> <s> <w></w> </s> <s> ... to get: (1 Reply)
Discussion started by: mjomba
1 Replies

7. Shell Programming and Scripting

Changing part of column value with AWK

Hi All , Here is my req I am extracting a column value and I want to change part of its value according to user input Say the column I extracted is of 15 digits and I want to change the 11th to 14th position with user input 4 digit value Example column value 111111111111111 user input... (8 Replies)
Discussion started by: Pratik4891
8 Replies

8. Shell Programming and Scripting

Delete part of string

This command: du -s /Applications/TextMate.app Returns an output like this: 65792 /Applications/TextMate.app I need to delete the space and the file path in the output leaving just the number. Thanks (2 Replies)
Discussion started by: pcwiz
2 Replies

9. Shell Programming and Scripting

column 1 line transitions part two!

I know I have already asked a similar question and the answer was awesome!...But it turns out I need something slightly different. I have a space delimited text file with thousands of lines, COLA.TXT that looks for example like this: AA 123 456 789 AA 987 987 987 AA 987 988 888 AA 999 999 999... (7 Replies)
Discussion started by: ajp7701
7 Replies

10. Shell Programming and Scripting

How to delete part of a file?

Suppose i have a file which contains 10 lines.... i have to delete a line which starts with the word "BEGIN" and delete the consecutive lines till i find a start of line with the word "END" how to do this? (6 Replies)
Discussion started by: brkavi_in
6 Replies
Login or Register to Ask a Question