---------- Post updated at 05:38 PM ---------- Previous update was at 05:37 PM ----------
can explain the working of the code it would be helpful
$1!=p ---> if field1 is not equal to p
p will not be equal to field1 in 2 condition, that is
1 ---> when awk read 1st line, p is not set
2 --->p is set, meaning we already read line before but field1 of current line is not equal p (assume p is previous line field1)
NR == 1 ? ---> if the line read by awk is 1st line then we are interested print only,
string "category"OFS(default is space) and column1 field$1
else, line read by awk is not first one, then print
string "ok" record separator RS (default is "\n") and print string "category"OFS(default is space) and column1 field$1
print "item",$2 ---> print string "item" and field2 $2, with output field separator being default (space)
p=$1 ---> set p is field1 read from current line, which will be used to compare with next line again $1!=p
END{print "ok"}---> The code in this block will be executed after executing all code, in short this is the last code going to execute in program, in current program it prints string "ok"
I need to rearrange the output but i am unable to arrange it to match the format. In the output i need NAME=\"To in the column .
Bash:
#!/bin/bash
cd /cygdrive/c/output/a
cat *.txt > output.txt
i=/cygdrive/c/output/a/output.csv
#echo "NE_Name, Source, Destination, OSPF_AREA_ID"... (4 Replies)
Hi there. I need to reformat a large file. Here is a sample of the file.
NETIK0102_UCS_Boot_a,NETIK0102_UCS_Boot_b
5200 2438 70G
5200 2439 70G
NETIK0102_UCS_HBA0_a,NETIK0102_UCS_HBA1_b,NETIK0102_UCS_HBA2_a,NETIK0102_UCS_HBA3_b
2673 19D7 55G
2673 19C0 30G
2673 19F5 120G... (5 Replies)
We have the following output:
server1_J00_data_20120711122243
server1_J00_igs_20120711122243
server1_J00_j2ee_20120711122243
server1_J00_sec_20120711122243
server1_J00_data_20120711131819
server1_J00_igs_20120711131819
server1_J00_j2ee_20120711131819
server2_J00_data_20120711122245... (10 Replies)
I am helping my wife set up a real estate site and I am starting to integrate MLS listings. We are using a HostGator level 5 VPS running CentOS and have full root and SSH access to the VPS.
Thus far I have automated the daily FTP download of listings from our MLS server using a little sh script.... (4 Replies)
I am definitely not an expert with awk, and I want to reformat a text file like the following. This is probably a very easy one for an expert out there. I would like to keep the lines in the same order, but move the heading to only be listed once above the lines.
This is what the text file... (7 Replies)
I am trying to write an awk program to reformat a data table and convert the date to julian time. I have all the individual steps working, but I am having some issues joing them into one program. Can anyone help me out? Here is my code so far:
# This is an awk program to convert the dates from... (4 Replies)