KEMBAR78
Unix Commands for Parcel and Booking Data Analysis | PDF | Computer Engineering | Computer Architecture
0% found this document useful (0 votes)
35 views3 pages

Unix Commands for Parcel and Booking Data Analysis

The document contains a series of Unix commands using awk to manipulate and extract data from text files related to parcel bookings and customer information. It includes commands to count delivered parcels, display specific booking details, find total bookings by a customer within a date range, filter customer records, update customer email, and sort booking details. Each command is tailored to process data formatted with specific delimiters and conditions.

Uploaded by

Domakonda Neha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

Unix Commands for Parcel and Booking Data Analysis

The document contains a series of Unix commands using awk to manipulate and extract data from text files related to parcel bookings and customer information. It includes commands to count delivered parcels, display specific booking details, find total bookings by a customer within a date range, filter customer records, update customer email, and sort booking details. Each command is tailored to process data formatted with specific delimiters and conditions.

Uploaded by

Domakonda Neha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

1)The file Parcel.

txt contains following data in the order

Customer ID | Booking ID | Booking Date | Receiver Name | Delivered address |


Amount |Status .
The fields are separated by a pipe (“|”).

Write a Unix command to count the number of Delivereded parcels

Customer ID|Booking ID|Booking Date|Receiver Name|Delivered address|Amount|Status


1|1001|15-02-2025|Sai|Hyderabad|2000|Inprocess
2|1002|17-02-2025|shiva|secunderabad|1500|Delivered
3|1003|17-02-2025|Ramya|secunderabad|3000|Delivered

awk 'BEGIN{FS="|";c=0;IGNORECASE=0}
NR>0 { if($7=="Delivered")
{
c=c+1;
}
}
END{print "Number of Delivered parcels:" c}'

2)You have a file having booking details. The file booking.txt file which contains
data in the following order:
Booking ID | CustomerName | Address | Rec_Name | Rec_Address | Date of Booking |
Par_Status

Write a Unix command to display the details of BookingID: "XXXX" in the given
order:
BookingId| CustomerName |Par_Status

If the given booking does not exist, then it should print "Booking details Not
Found"

Booking ID|CustomerName|Address|Rec_Name|Rec_Address|DateOfBooking|Par_Status
101|Neha|Secunderabad|Neha|Secunderabad|16-02-2025|Inprocess
102|Priya|Hyderabad|Priya|Hyderabad|16-02-2025|Delivered
103|Riya|Ammerpet|Riya|Hyderabad|16-02-2025|Approved

awk 'BEGIN{FS="|";c=0;s=""}
NR>0{if($1==102)
{
c=c+1;
s= $1"|"$2"|"$7;
}

}
END{if(c==0)
{
print " Not found ";
}
else
{
print s;
}
}'
3)You have a file with booking details of all consumers for the last 3 months in
the given order.
Booking ID | CustomerName | Address | Rec_Name | Rec_Address | Date of Booking |
Par_Status

Write a unix command that find the total number of bookings done by a customer
within a date range and prints the result in below format in descending order:

Booking ID | CustomerName |No of bookings

Booking ID|CustomerName|Address|Rec_Name|Rec_Address|DateOfBooking|Par_Status
101|Neha|Secunderabad|Neha|Secunderabad|16-02-2025|Inprocess
102|Neha|Hyderabad|Priya|Hyderabad|17-02-2025|Delivered
103|Riya|Ammerpet|Riya|Hyderabad|18-02-2025|Approved

awk 'BEGIN{FS="|";cc=0;ss=""}
NR>1{
if($2=="Neha" && ($6>="2025-02-16" && $6<="2025-02-18"))
{
cc=cc+1;
print $1"|"$2"|"cc;

}
END{

}' | sort -t "|" -k1nr

4)The file customer.txt contains following data in the order

Customer ID, Customer Name , Address, Email , Mobile


The fields are separated by a comma (“,”).

Write a Unix command to display the records where customer name starts with "An"
Customer ID,Customer Name,Address,Email,Mobile
101,Neha,Secunderabad,neha@gamil.com,9454564653
102,Ankit,hyderabad,ankit@gmail.com,9876543212
103,Annanya,Warangal,ann@gmail.com,9647283643

awk ' BEGIN{FS=","}


NR>1{if($2 ~ /^An/) // if($2 ~ /An*/)
{
print $1","$2","$3","$4","$5
}
}
END{ }'

5)The file customer.txt contains following data in the order

Customer ID, Customer Name , Address, Email , Mobile


The fields are separated by a comma (“,”).
Write a Unix command to update the email of a customer.
Customer ID,Customer Name,Address,Email,Mobile
101,Neha,Secunderabad,neha@gamil.com,9454564653
102,Ankit,hyderabad,ankit@gmail.com,9876543212
103,Annanya,Warangal,ann@gmail.com,9647283643

awk 'BEGIN{FS=","}
NR>1{
if($1==101)
{
$4="domakonda@gmail.com";
print $1","$2","$3","$4","$5
}
}
END{}'

6)You have a file having booking details. The file booking.txt file which contains
data in the following order:
Booking ID | CustomerName | Address | Rec_Name | Rec_Address | Date of Booking |
Par_Status

Write a Unix command to display the below details in descending order of booking id
BookingId| CustomerName |Date of Booking

Booking ID|CustomerName|Address|Rec_Name|Rec_Address|DateOfBooking|Par_Status
101|Neha|Secunderabad|Neha|Secunderabad|16-02-2025|Inprocess
102|Neha|Hyderabad|Priya|Hyderabad|17-02-2025|Delivered
103|Riya|Ammerpet|Riya|Hyderabad|18-02-2025|Approved

awk 'BEGIN{FS="|"}
NR>1{
print $1","$2","$3","$4","$5
}
END{}' | sort -t "," -k1nr

You might also like