Sponsored Content
Full Discussion: Parsing data
Top Forums Shell Programming and Scripting Parsing data Post 302408857 by frans on Tuesday 30th of March 2010 05:04:40 PM
Old 03-30-2010
Should this do what's wanted ?
Code:
#!/bin/bash
OLDIFS=$IFS; IFS='!'
while read -a L
do
    LINE=""
    for ((i=1; i<$((${#L[@]}-2)); i++))
    do
        if ((i<3))
        then    LINE+="$(echo "${L[$i]}" | cut -d':' -f2)- "
        else    LINE+="$(echo "${L[$i]}" | cut -d' ' -f3-)- "
        fi
    done
    echo "Part 1 : $LINE"
    echo -n "Part 2 : "
    echo ${L[8]} | cut -d' ' -f3- | sed -e 's/<[^<]*><[^<]*>/ - /g' -e 's/<[^<]*>//g'
    echo "------------------"
done < infile
IFS=$OLDIFS

Result:
Code:
Part 1 :  1 -  101 - 04/03/2010 14:08:24 - acc_22640827031004 - labs101 - CYCL_ST - 2898381018 - 
Part 2 : 00092898381018 - Mobility - 10.00 - 0.50 -  - Active -  -  -  -  - 10.00 - 0.50 - 302612898381018  
------------------
Part 1 :  2 -  101 - 04/03/2010 15:59:59 - acc_1234567890 - labs101 - CYCL_ST - 7805250631 - 
Part 2 : 007805250631 - Mobility - 0.00 - 0.00 -  - Active -  -  -  -  - 0.00 - 0.00 - 000007805250631 
------------------
Part 1 :  3 -  101 - 04/03/2010 15:26:22 - acc_1234567890 - labs101 - CYCL_ST - 7805250631 - 
Part 2 : 007805250631 - Mobility - -10.00 - 0.00 -  - Inactive -  -  -  -  - -10.00 - 0.00 - 000007805250631 
------------------
Part 1 :  4 -  101 - 04/03/2010 12:33:33 - acc_22640827031004 - labs101 - CYCL_ST - 2898381018 - 
Part 2 : 00092898381018 - Mobility - 10.00 - 0.50 -  - Inactive -  -  -  -  - 10.00 - 0.50 - 302612898381018 
------------------

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing the data in a file

Hi, I have file (FILE.tmp) having contents, FILE.tmp ======== filename=menudata records=0000000000037 ldbname=pinsys timestamp=2005/05/14-18:32:33 I want to parse it bring a new file which will look like, filename records ldbname timestamp... (2 Replies)
Discussion started by: Omkumar
2 Replies

2. Shell Programming and Scripting

Parsing the data

Hi I need to parse the following data using shell script Table ----- stage4n_abc 48 stage4o_abcd 4 adashpg_abc_HeartBeat 1 stage4l_asc 168 Can anyone gimme the solution. I want each value to get stored in an array or variable and want the value to be greped from another file.... (1 Reply)
Discussion started by: Archana.Dheepan
1 Replies

3. Shell Programming and Scripting

More efficent Data Parsing

I am looking for a way to parse out some numbers from text. This is an excerpt from a larger script that I am trying to make run a little smoother. Specifically this script is used to Capture DV video streams on a linux machine from the terminal. The setup does 6 streams at once, and this part... (3 Replies)
Discussion started by: Starcast
3 Replies

4. Shell Programming and Scripting

Parsing the data

Hi friends, I need to parse the following data in the given format and get the desired output. I need a function, which takes the input as a parameter and the desired output will be returned from the function. INPUT(single parameter as complete string) A;BCF;DFG;FD ... (3 Replies)
Discussion started by: sumesh.1988
3 Replies

5. Shell Programming and Scripting

Help in Parsing data

I have below string Transaction_ID:SDP-DM-151204679 , Transaction_DateTime:2011-02-11 00:00:15 GMT+05:30 , Transaction_Mode:WAP , Circle_ID:4 , Circle_Name:BJ ,Zone: , CustomerID:B_31563486 , MSISDN:7870904329 , IMSI:405876122068099 , IMEI: , Sub_Profile:Pre-Paid , CPID:Nazara , CPNAME:Nazara ,... (6 Replies)
Discussion started by: poweroflinux
6 Replies

6. Shell Programming and Scripting

Data parsing

Hi, I do have a data file which is divided into compartments by ---------. I would like to extract (parse) some of the data and numbers either using awk or sed The file has the format: CATGC Best GO enrichment: Genes/ORF that have the motifs (genes are sorted by max(pa+pd+po)): ... (6 Replies)
Discussion started by: Lucky Ali
6 Replies

7. Shell Programming and Scripting

Help with parsing data with awk , eliminating unwanted data

Experts , Below is the data: --- Physical volumes --- PV Name /dev/dsk/c1t2d0 VG Name /dev/vg00 PV Status available Allocatable yes VGDA 2 Cur LV 8 PE Size (Mbytes) 8 Total PE 4350 Free PE 2036 Allocated PE 2314 Stale PE 0 IO Timeout (Seconds) default --- Physical volumes ---... (5 Replies)
Discussion started by: rveri
5 Replies

8. Shell Programming and Scripting

Parsing file data

Hey Guys, I'm a novice at shell scripts and i need some help parsing file data. Basically, I want to write a script that retrieves URLs. Here is what I have so far. #!/bin/bash echo "Please enter start date (format: yyyy-mm-dd):\c" read STARTDATE echo "Please enter end date... (7 Replies)
Discussion started by: silverdust
7 Replies

9. Shell Programming and Scripting

Parsing XML (and insert data) then output data (bash / Solaris)

Hi folks I have a script I wrote that basically parses a bunch of config and xml files works out were to add in the new content then spits out the data into a new file. It all works - apart from the xml and config file format in the new file with XML files the original XML (that ends up in... (2 Replies)
Discussion started by: dfinch
2 Replies

10. Shell Programming and Scripting

Parsing Bulk Data

Hi All, :D Actullay I am looking for a smart way :b: to parse files in a directory whose count is around 2000000 :eek: in a single day. Find is working with me but taking a lot of times :confused:, sometimes even a day which is not helping me.:wall: So anyone can help me know a smart... (5 Replies)
Discussion started by: jojo123
5 Replies
shells(4)							   File Formats 							 shells(4)

NAME
shells - shell database SYNOPSIS
/etc/shells DESCRIPTION
The shells file contains a list of the shells on the system. Applications use this file to determine whether a shell is valid. See getuser- shell(3C). For each shell a single line should be present, consisting of the shell's path, relative to root. A hash mark (#) indicates the beginning of a comment; subsequent characters up to the end of the line are not interpreted by the routines which search the file. Blank lines are also ignored. The following default shells are used by utilities: /bin/bash, /bin/csh, /bin/jsh, /bin/ksh, /bin/pfcsh, /bin/pfksh, /bin/pfsh, /bin/sh, /bin/tcsh, /bin/zsh, /sbin/jsh, /sbin/sh, /usr/bin/bash, /usr/bin/csh, /usr/bin/jsh, /usr/bin/ksh, /usr/bin/pfcsh, /usr/bin/pfksh, /usr/bin/pfsh, and /usr/bin/sh, /usr/bin/tcsh, /usr/bin/zsh. Note that /etc/shells overrides the default list. Invalid shells in /etc/shells may cause unexpected behavior (such as being unable to log in by way of ftp(1)). FILES
/etc/shells lists shells on system SEE ALSO
vipw(1B), ftpd(1M), sendmail(1M), getusershell(3C), aliases(4) SunOS 5.10 4 Jun 2001 shells(4)
All times are GMT -4. The time now is 10:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy