Isolate first characters until specified point


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Isolate first characters until specified point
# 1  
Old 02-04-2014
Isolate first characters until specified point

Hi everyone, I am in a pickle.
I need to isolate an element of each line.
I have data that looks like this:

Code:
about+n+n-talk-n
about+ns+ns-talk-n
about+ns+n-talk-n
about+ns+v-say-v
as+n-a-j+vp-look-v
as+ns+v-come-v
as+ns+vn-list-v

and I need to isolate all the characterts until the FIRST "+"
so the ideal output would be as follows:

Code:
about n+n-talk-n
about ns+ns-talk-n
about ns+n-talk-n
about ns+v-say-v
as n-a-j+vp-look-v
as ns+v-come-v
as ns+vn-list-v

I used a similar code for awk but am at a loss to adapt it.
Can anyone help?
Thank you!
# 2  
Old 02-04-2014
What have you tried so far?
# 3  
Old 02-04-2014
I have tried the following:

Code:
awk '$1~/-n$/ {sub (/*+*$/," &", $1); $0=$0; sub (/^+/,"",$1); print}' file

# 4  
Old 02-04-2014
Something like this?
Code:
awk '{sub("+"," ")}1 ' file

This User Gave Thanks to Franklin52 For This Post:
# 5  
Old 02-04-2014
Hi, try:
Code:
sed 's/+/ /' file

This User Gave Thanks to Scrutinizer For This Post:
# 6  
Old 02-04-2014
Code:
sed 's/+/ /' file

replaces first + to a space...
This User Gave Thanks to neutronscott For This Post:
# 7  
Old 02-04-2014
They all work! Thank you so much for the help!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to create a new mount point with 600GB and add 350 GBexisting mount point? IN AIX

How to create a new mount point with 600GB and add 350 GBexisting mount point Best if there step that i can follow or execute before i mount or add diskspace IN AIX Thanks (2 Replies)
Discussion started by: Thilagarajan
2 Replies

2. Shell Programming and Scripting

Isolate text with sed or similar utility

All, I'm getting a list like the following and I'd like to kill each PID in turn. pid (17797) pid (21748) pid (21754) pid (21704) pid (2199) pid (2159) pid (17809) pid (21769) pid (21778) pid (21715) ... (3 Replies)
Discussion started by: ejianu
3 Replies

3. Shell Programming and Scripting

How to perform a hexdump using dd from start point to end point?

hi, I would like to ask or is it possible to dump a hex using dd from starting point to end point just like the "xxd -s 512 -l 512 <bin file>" I know the redirect hexdump -C but i can't figure it out the combination options of dd. Hope someone can share their knowledge.. Thanks in... (3 Replies)
Discussion started by: jao_madn
3 Replies

4. Shell Programming and Scripting

Using awk to isolate specific rows

Hi all! Let's say I have obtained this dataset from the ISI Web of Knowledge ... PT J AU Yousefi, Ramin Muhamad, Muhamad Rasat Zak, Ali Khorsand TI The effect of source temperature on morphological and optical properties of ZnO nanowires grown using a modified thermal... (17 Replies)
Discussion started by: sidiqmk
17 Replies

5. Shell Programming and Scripting

awk: isolate a part of a file name

hi there, i have a file named 'x20080613_x20100106.pwr1.gc', i want to isolate the part 'x20080613_x20100106' but by using the following line i isolate the part '.pwr1.gc': `awk '$0=substr($0, length($0)-7)' $temp` how can i reverse that? thank you! (3 Replies)
Discussion started by: friend
3 Replies

6. UNIX for Dummies Questions & Answers

isolate unique files in a folder

Hello, I have two folders. One has 1183 text files (folder A). The other (folder B) has 1160 of those 1183 files (the contents in these 1160 files are identical to the contents in the corresponding files in the other folder, but the names of the files in this folder are completely different... (2 Replies)
Discussion started by: juliette salexa
2 Replies

7. Shell Programming and Scripting

Removing all characters on and before specific point

Im having a file with records DB1635 |Y|N|DB1632 |000024968_202 |0|000024968302|RCF02| DB1636 |Y|N|DB1633 |000024968_203 |0|000024968302|RCF02| i want to get output as Y|DB1632 |RCF02| Y|DB1633 |RCF02| how can i do this ?? any... (3 Replies)
Discussion started by: Trendz
3 Replies

8. UNIX for Dummies Questions & Answers

how can i isolate the random sequence of numbers using awk?

as you can see there is a delimiter after c8 "::". Awk sees the rest as fields because it doesn't recognize spaces and tabs as delimiters. So i am basically looking to isolate 20030003ba13f6cc. Can anyone help? c8::20030003ba13f6cc disk connected configured unknown (2 Replies)
Discussion started by: rcon1
2 Replies

9. UNIX for Dummies Questions & Answers

is LS a fixed length? I want to use cut -c#-# to isolate filename.

-rw-r--r-- 1 fxpbftp fusion 368 Jun 10 08:34 FX_1.11840235236594E12.111234236809956 If I have a long list of files that look like this (they al begni with FX_1.#######.####) Sometimes, there may be less numbers or more in the filename, that varies. I wish to isolate just the... (8 Replies)
Discussion started by: yongho
8 Replies

10. UNIX for Advanced & Expert Users

Fibre connection Point to Point SUN

Anyone know of a guide or instructions for Solaris I got to configure a SBUS HBA to talk to a tape robot. I have done this on a switch but not point to point. just going HBA >>>>> TAPE Fibre simple two nodes Kie (6 Replies)
Discussion started by: kie
6 Replies
Login or Register to Ask a Question