awk to seperate a string that has a dash


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers awk to seperate a string that has a dash
# 1  
Old 08-21-2008
awk to seperate a string that has a dash

Hello


I have this string

XYZ-ABC
DFT-ERT
QWE-TYU

I want to get the part after the dash. how to do that?

thanks
# 2  
Old 08-21-2008
the correct examples are

XYZ-ABC
XYZ-ERT
XYZ-TYU

meaning the first part XYZ does not change
# 3  
Old 08-21-2008
awk -F"-" '{print $2}' filename_where_you_have_the_examples
or
cut -d"-" -f2 filename_where_you_have_the_examples
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A dash to GOTO or a dash from GOTO, that is the question...

Well, guys I saw a question about GOTO for Python. So this gave me the inspiration to attempt a GOTO function for 'dash', (bash and ksh too). Machine: MBP OSX 10.14.3, default bash terminal, calling '#!/usr/local/bin/dash'... This is purely a fun project to see if it is possible in PURE... (3 Replies)
Discussion started by: wisecracker
3 Replies

2. Shell Programming and Scripting

awk to filter file based on seperate conditions

The below awk will filter a list of 30,000 lines in the tab-delimited file. What I am having trouble with is adding a condition to SVTYPE=CNV that will only print that line if CI= must be >.05 . The other condition to add is if SVTYPE=Fusion, then in order to print that line READ_COUNT must... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

4. Shell Programming and Scripting

Extracting string before first dash in a file name

Hi all, Given a file name such as EXAMPLE=lastname-02.30.71-firstname-town-other.tar.gz How do I print everything before the first dash (i.e. lastname) Note: I do not know exactly how many dashes or what information there will be in each file name so it is important that the code... (2 Replies)
Discussion started by: bashnewbee
2 Replies

5. Shell Programming and Scripting

How to concatenate string containing a leading dash?

Is there a way to concatenate two strings, where the first string is "-n" and there is a space between the "-n" and the second string? Below are some examples of what I tried. #!/bin/sh var1=test #working without dashes: var2="n $var1" echo $var2 var2=n" "$var1 echo $var2 var2="n... (5 Replies)
Discussion started by: wolfv
5 Replies

6. Shell Programming and Scripting

Seperate complicated fields with awk

Hello, I want to separate fields from an log output like this: 11-JUL-2008 23:14:25 * (CONNECT_DATA=(SERVICE_NAME=WUMMER.IM.HERE.EXELLENT.COM)(CID=(PROGRAM=D:\oracle\product\10.2.0\client_1\jdk\jre\bin\java.exe)(HOST=X900005199)(USER=FTET1))) *... (6 Replies)
Discussion started by: sdohn
6 Replies

7. Shell Programming and Scripting

remove dash

hi I am using ksh #A="abc-def" #typeset -u B="$A" #echo $B ABC-DEF how to remove the dash? i.e. ABCDEF? thank you (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

8. Shell Programming and Scripting

how to awk a data from seperate lines

Hi guys, i have a problem which im hoping you will be able to help me with. I have follwing output :- ------------------------------------------------------------------------------- NSTEP = 407000 TIME(PS) = 43059.000 TEMP(K) = 288.46 PRESS = 0.0 Etot = -2077.4322 ... (2 Replies)
Discussion started by: Mish_99
2 Replies

9. Shell Programming and Scripting

how to seperate space in a string

Dear Members, I have string like this string1="file2.txt file4.txt kittu.txt file1.txt" in this i need to cut spaces and take each one has one file output should be --------- fileslist:4 file2.txt file4.txt kittu.txt file1.txt is it possible, please tell me how it possible ... (5 Replies)
Discussion started by: kittusri9
5 Replies
Login or Register to Ask a Question