Hi Team,
i have some script which give output in TXT format , need script to convert TXT file into CSV.
Output.TXT
Need to convert it into CSV like this
I try some script like...
it is not giving proper CSV file output
i have some script which give output in TXT format , need script to convert TXT file into CSV.
Output.TXT
Code:
413. U-UU-LVDT-NOD-6002 [NOD_4406] macro_outcome_dist-8.0.0(v1_0_2) KK:1.2.494 (1234:333:aaa:2333:3:2:333:a)
414. U-UU-LVDT-NOD-6004 [NOD_3805] macro_outcome_dist-8.0.0(v1_0_2) KK:1.2.589 (1234:333:aaa:2333:3:2:333:e)
415. U-UU-LVDT-NOD-6005 [NOD_4288] macro_outcome_dist-8.0.0(v1_0_2) KK:1.2.349 (1234:333:aaa:1400:3:2:333:1e)
416. U-UU-LVDT-NOD-6006 [NOD_2810] macro_outcome_dist-8.0.0(v1_0_2) KK:1.2.352 (1234:333:aaa:a00:3:2:333:7a)
417. U-UU-LVDT-NOD-6008 [NOD_2803] macro_outcome_dist-8.0.0(v1_0_2) KK:1.2.613 (1234:333:aaa:a00:3:2:333:66)
418. U-UU-LVDT-NOD-9006 [NOD_2320] macro_outcome_dist-8.0.0(v1_0_2) KK:1.2.618 (1234:333:aaa:1400:3:2:333:22)
419. U-UU-LVDT-NOD-9014 [NOD_2095] macro_outcome_dist-8.0.0(v1_0_2) KK:1.2.347 (1234:333:aaa:a00:3:2:333:d6)
Need to convert it into CSV like this
Code:
NODE ID IP
U-UU-LVDT-NOD-6002 4406 1234:333:aaa:2333:3:2:333:a
U-UU-LVDT-NOD-6004 3805 1234:333:aaa:2333:3:2:333:e
U-UU-LVDT-NOD-6005 4288 1234:333:aaa:1400:3:2:333:1e
U-UU-LVDT-NOD-6006 2810 1234:333:aaa:a00:3:2:333:7a
I try some script like...
Code:
grep -F "NOD" /home/lotus/bin/Output.TXT | cut -d ' ' -f3 | cut -c7- | cut -d '' -f1 | sed 's/\(.*\)...../\1/' > /home/lotus/bin/p1.csv
grep -F "NOD" /home/lotus/bin/Output.TXT | cut -d ' ' -f2 | cut -c6- | cut -d '' -f1 | sed 's/\(.*\)..../\1/' >> /home/lotus/bin/p1.csv
Moderator's Comments: | ||
|