Unix Practice Stmts

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

You have a file representing the data for different products available in a store.

Please
find below example data in a file separated by "@".

Product_Name@Price@Payment_Method@IsPrime
iPhone 11@42000@UPI@No
Macbook Air@88000@Card@No
S21 Ultra@105000@Card@Yes
Chromebook@40000@COD@Yes
LaserJet@5200@Net_Banking@Yes
iPhone 13 Mini@72000@Card@Yes

Write the Unix command to print the details of prime products with prices higher than
4999.

Note: A product is prime if its IsPrime value is "Yes".

The file name will be provided as a command-line argument when the script containing
your command will run.

You can use shell variables (e.g. $0,$1,$2) whichever is applicable for your
requirement to providing the command line argument.

For more clarity, please refer to the Sample Input and Output below.

Note:
The file is automatically loaded with the input records of the company in the above-
specified order and format. You just need to implement the script/command by
assuming that the input file is supplied as a first command-line argument to the script
or command.

Sample Input:
Product_Name@Price@Payment_Method@IsPrime
iPhone 11@42000@UPI@No
Macbook Air@88000@Card@No
S21 Ultra@105000@Card@Yes
Chromebook@40000@COD@Yes
LaserJet@4998@Net_Banking@Yes
iPhone 13 Mini@72000@Card@Yes

Sample Output:
S21 Ultra@105000@Card@Yes
Chromebook@40000@COD@Yes
iPhone 13 Mini@72000@Card@Yes
You have a file having order amount details of customers for orders placed.
The format of the file is as below ('-' is the field delimiter):

CustID-Order1-Order2-Order3
C101-55-12-12
C234-67-42-13
C341-90-90-90
C511-40-40-40

Write the Unix command to print the record of those Customers whose total order
amount is >=200. i.e. the summation of Order1, Order2 and Order3 is greater than
equal to 200. Also print the total count of such customers at the end as "Total :"
(without the quotes). Please refer to the sample output for clarity.

The file name will be provided as a command line argument when the script containing
your command will run.
You can use shell variables (e.g. $0,$1,$2) whichever is applicable for your
requirement to provide the command line argument.

For more clarity on inputs and outputs, please refer to the sample input and output
below.

Note: In case there are no records fulfilling the given condition, value for total
count should be 0 (zero). Refer to sample below.

Sample Input 1 :
CustID-Order1-Order2-Order3
C101-55-12-12
C234-67-42-13
C341-90-90-90
C511-40-40-40

Output :
C341-90-90-90
Total : 1

Sample Input 2 :
CustID-Order1-Order2-Order3
C101-55-12-12
C234-67-42-13
C341-13-10-90
C511-41-40-40

Output :
Total : 0

You might also like