Split word


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Split word
# 1  
Old 03-05-2014
Split word

Hi,

I have file like below

Code:
NN3EN3   UKLND  JESSICA             PETER            BANK SYSTEMS  BANK SYSTEMS                  21514           LON    PROJECT    LEADPROJECT LEAD                 340934742          PETER
 
 
N34ZG4   UKLND  SCOTT           TAILER          PEOPLE CORP GRPPEOPLE CORPORATE GROUPS       22023           ENG     MANAGER HR     MANAGER HUMAN RESOURCES       Y           +0498248543

I want to take user job position which is marked in red text.

Marked in blue text is user id, for usr id NN3EN3 job position is clubbed together like LEADPROJECT but I want take PROJECT LEAD.
Also the job position is different places so the column also diffrent palces.

please help me how to take job position as PROJECT LEAD for usrid NN3EN3

MANAGER HR for usrid N34ZG4
# 2  
Old 03-05-2014
Code

Use below script to convert the file into csv and then strip out your fields

Code:
while read rec
do
        txt=`echo $rec|grep [a-zA-Z]`
        if [ ! -z $txt ]
        then
        newrec=
        echo $rec|tr ' ' '\n'|grep -v ^' '>/tmp/tmp_rec
        while read sub_rec
        do
                        if [ -z $newrec ]
                        then
                        newrec=`echo $sub_rec,`
                        else
                        newrec=`echo $newrec,$sub_rec`
                        fi
        done</tmp/tmp_rec
        echo $newrec>>/tmp/rec.csv
        fi
done<split_word

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read a File line by line and split into array word by word

Hi All, Hope you guys had a wonderful weekend I have a scenario where in which I have to read a file line by line and check for few words before redirecting to a file I have searched the forum but,either those answers dint work (perhaps because of my wrong under standing of how IFS... (6 Replies)
Discussion started by: Kingcobra
6 Replies

2. Shell Programming and Scripting

awk to split one field and print the last two fields within the split part.

Hello; I have a file consists of 4 columns separated by tab. The problem is the third fields. Some of the them are very long but can be split by the vertical bar "|". Also some of them do not contain the string "UniProt", but I could ignore it at this moment, and sort the file afterwards. Here is... (5 Replies)
Discussion started by: yifangt
5 Replies

3. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

4. Programming

import .txt and split word into array C

Hi, if I want to import .txt file that contain information and the number separate by space how can I split and put into array In C Example of .txt file 3 Aqaba 49789 10000 5200 25.78 6987 148976 12941 15.78 99885 35262 2501 22.98 Thank (3 Replies)
Discussion started by: guidely
3 Replies

5. Shell Programming and Scripting

split word

Hi all, Infile: 1|2|3|test james ke the one |value 1|2|3|test the value|comp 1|2|3|test james|value 1|2|3|one two three|value I need split the 4th delimiter value into 3 fields based on below condition.if 4th field contains "ke loc" or "the" then i should not consider it is word and... (6 Replies)
Discussion started by: Jairaj
6 Replies

6. Shell Programming and Scripting

How do you split a sentence after every nth word

Hi, I think my problem is a "simple" one to resolve. What i am looking for is a way in sed/awk to split a long line/paragraph into say 5 words per line. For example: Sentence/paragraph contains: 102 103 104 105 106 107 109 110 .... I would like the output to be (if splitting every 5... (5 Replies)
Discussion started by: muay_tb
5 Replies

7. Solaris

Split a file which a word criteria in two files with awk

Hello, I'm searching with the Awk command to split a file into two others files. I explain : in the file N1 I search the word "NameVirtual" and since that word to the end of the file I want to store all lines in a new file N2 Also from that word to the beginning of the file I want to... (11 Replies)
Discussion started by: steiner
11 Replies

8. Shell Programming and Scripting

Split a word in short words

Dear, Can somebody help me with this? I have a variable TGT=T2DIRUPDAZ20070326VA I want to get in variables some part of TGT. like this. TGT1=UPDA TGT2=20070326 TGT3= VA These three variables have fixe position in variable TGT. (2 Replies)
Discussion started by: yeclota
2 Replies

9. UNIX for Dummies Questions & Answers

Split a file with no pattern -- Split, Csplit, Awk

I have gone through all the threads in the forum and tested out different things. I am trying to split a 3GB file into multiple files. Some files are even larger than this. For example: split -l 3000000 filename.txt This is very slow and it splits the file with 3 million records in each... (10 Replies)
Discussion started by: madhunk
10 Replies

10. Shell Programming and Scripting

Can a shell script pull the first word (or nth word) off each line of a text file?

Greetings. I am struggling with a shell script to make my life simpler, with a number of practical ways in which it could be used. I want to take a standard text file, and pull the 'n'th word from each line such as the first word from a text file. I'm struggling to see how each line can be... (5 Replies)
Discussion started by: tricky
5 Replies
Login or Register to Ask a Question

Featured Tech Videos