Sponsored Content
Top Forums Shell Programming and Scripting Need to format string to collate data of similar IP address. Post 303042647 by mohtashims on Thursday 2nd of January 2020 02:33:15 AM
Old 01-02-2020
@nezabudka here is the output:

For:
Code:
while read -r fline; do
       ((counter++))
       echo "$fline" | sed 's/\\n/\n/g'
       echo $counter
done <<< "$str1"

Output:
Code:
./test2.sh 
10.9.11.128
-rwxr-xr-x user1 2019-12-29 17:53 /var/branch/custom/tg.xml 286030210
10.9.12.129
-rwxr-xr-x user1 2019-12-29 17:53 /app/branch/custom/tg.xml 286030210
10.9.20.130
-rwxr-xr-x user1 2019-12-29 17:53 /web/branch/custom/tg.xml 286030210
10.9.11.128
-rwxr-xr-x user1 2019-12-29 17:53 /web/branch/custom/mg.xml 286030210
-rwxr-xr-x user1 2019-12-29 17:53 /web/branch/custom/nog.xml 999997
1

For:
Code:
while read fline; do
        ((count++))
        echo "$fline"
        echo $count
done < <(echo -e $str1)

Output:
Code:
./test1.sh 
10.9.11.128
1
-rwxr-xr-x user1 2019-12-29 17:53 /var/branch/custom/tg.xml 286030210
2
10.9.12.129
3
-rwxr-xr-x user1 2019-12-29 17:53 /app/branch/custom/tg.xml 286030210
4
10.9.20.130
5
-rwxr-xr-x user1 2019-12-29 17:53 /web/branch/custom/tg.xml 286030210
6
10.9.11.128
7
-rwxr-xr-x user1 2019-12-29 17:53 /web/branch/custom/mg.xml 286030210
8
-rwxr-xr-x user1 2019-12-29 17:53 /web/branch/custom/nog.xml 999997
9

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

converting a tabular format data to comma seperated data in KSH

Hi, Could anyone help me in changing a tabular format output to comma seperated file pls in K-sh. Its very urgent. E.g : username empid ------------------------ sri 123 to username,empid sri,123 Thanks, Hema:confused: (2 Replies)
Discussion started by: Hemamalini
2 Replies

2. Shell Programming and Scripting

bash: convert mac address to 16 character format

Hi there Im not quite sure how i can do this, but i am retrieving the mac address from boxes, which in some instances is arriving in its shortened format (i.e. dropping the leading zeros)... for example 0:3:BA:1:E:84 Im trying to figure out a way of converting the single character... (3 Replies)
Discussion started by: rethink
3 Replies

3. Shell Programming and Scripting

Searching String from set of similar File pattern from the Dir

Guys, Here is the script that searches string from the set of similar files from the log directory, All the file patterns are defined as input file, from where the script should map to those files in the LOG_DIR and should start searching the strings from all those similar files. ... (1 Reply)
Discussion started by: raghunsi
1 Replies

4. Shell Programming and Scripting

IP address to decimal format conversion

I have a file which consist of some class 4 IP address as 172.16.112.50 172.16.112.50 172.16.112.50 172.16.112.100 192.168.1.30 172.16.112.100 172.16.112.50 172.16.112.50 172.16.112.50 i want to store them in pure decimal notations instead of the given dotted decimal formats e.g.... (2 Replies)
Discussion started by: vaibhavkorde
2 Replies

5. Shell Programming and Scripting

appending data from similar files

I am familiar with scripting, but I am trying to see if there is an easy way to append files from similar files into one file. For example, if there is file1_20121201, file1_20121202, file1_20121203, file2_20121201, file2_20121202, file2_20121203 I want to be able to combine all the data from... (3 Replies)
Discussion started by: mrbean1975
3 Replies

6. Shell Programming and Scripting

capturing the value in file before string(*) and the similar value in next line only

I've the output in the file like below. I want to capture the value in file before string(*) and the similar value in next line only. cat test1.txt 0003 Not Visible (M) 0 00 03F 0005 Not Visible (M) 0 00 040 - AVAILABLE 0 00... (1 Reply)
Discussion started by: sai_1712
1 Replies

7. Shell Programming and Scripting

Kindly check:remove duplicates with similar data in front of it

Hi all, I have 2 files containing data like this: so if there is same entry repeated in the column like1,2,3,4 I have to check if there is different entries column like 2,4 but similar entries for duplicatein column 2 like1,3 the output shuld be like this for first file ... (5 Replies)
Discussion started by: manigrover
5 Replies

8. Shell Programming and Scripting

To search for a particular tag in xml and collate all similar tag values and display them count

I want to basically do the below thing. Suppose there is a tag called object1. I want to display an output for all similar tag values under heading of Object 1 and the count of the xmls. Please help File: <xml><object1>house</object1><object2>child</object2>... (9 Replies)
Discussion started by: srkmish
9 Replies

9. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

10. Shell Programming and Scripting

How to group similar data?

Hello everybody: I want rearrange about 5 million rows (with 300 columns) into groups. Data looks like the following: where there were various experiments (column 2) conducted at different locations (column headers in top row column 4 onwards) in different years (column 1) using instruments... (0 Replies)
Discussion started by: sheetalk
0 Replies
AP(8)								     [nmh-1.5]								     AP(8)

NAME
ap - parse addresses 822-style SYNOPSIS
/usr/lib/mh/ap [-form formatfile] [-format string] [-normalize | -nonormalize] [-width columns] [-version] [-help] addrs ... DESCRIPTION
Ap is a program that parses addresses according to the ARPA Internet standard. It also understands many non-standard formats. It is use- ful for seeing how nmh will interpret an address. The ap program treats each argument as one or more addresses, and prints those addresses out in the official 822-format. Hence, it is usu- ally best to enclose each argument in quotes for the shell. To override the output format used by ap, the -format string or -format file switches are used. This permits individual fields of the address to be extracted with ease. The string is simply a format string, and the file is simply a format file. See mh-format(5) for the details. In addition to the standard escapes, ap also recognizes the following additional escape: Escape Returns Description error string A diagnostic if the parse failed If the -normalize switch is given, ap will try to track down the official hostname of the address. Here is the default format string used by ap: %<{error}%{error}: %{text}%|%(putstr(proper{text}))%> which says that if an error was detected, print the error, a `:', and the address in error. Otherwise, output the 822-proper format of the address. FILES
$HOME/.mh_profile The user profile /etc/nmh/mts.conf nmh mts configuration file PROFILE COMPONENTS
None SEE ALSO
dp(8), Standard for the Format of ARPA Internet Text Messages (RFC-822) DEFAULTS
`-format' defaults as described above `-normalize' `-width' defaults to the width of the terminal CONTEXT
None BUGS
The argument to the -format switch must be interpreted as a single token by the shell that invokes ap. Therefore, one must usually place the argument to this switch inside quotes. MH.6.8 11 June 2012 AP(8)
All times are GMT -4. The time now is 04:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy