Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

using awk and cat and grep

# get cities as unique form 
uniq=$( cat $1 |awk -F "," '{print $2}' | sort -u)

## loop in the list of uniq cities 
for UniqCity in $uniq ; do

          # grep all field where city appears 
                                ## sort according to temporary from bigger to smaller 
                                           #take the 3rd column{temporary} 
                                                          # take the larger temporary which appears and the first line
  maxTemp=$(grep $UniqCity $1 | sort -nr | cut -f3 -d"," | head -n1  )
  # count number of lines 
  lines=$(cat $1 | wc -l)

  # sum of temporary according to city 
  Total=$(grep $UniqCity $1| awk -F "," '{print $3}'  | awk '{s+=$1} END {print  s}')

  avg=$(expr $Total / $lines) 
  echo "City:$UniqCity"
  echo "max: $maxTemp"
  echo "avg: $avg"
 
Comment

PREVIOUS NEXT
Code Example
Shell :: i cant update snapstore app 
Shell :: ssh key meaning 
Shell :: how to apply password to folder and file shell scripting in linux 
Shell :: Fix for infinite log Linux bug 
Shell :: virtual machine linux error several modules to compile 
Shell :: how to download octave in ubuntu 
Shell :: git commands cheat sheet pdf 
Shell :: find linux distro 
Shell :: git revert file 
Shell :: bash list process 
Shell :: github clone 
Shell :: command to kill port in linux 
Shell :: error: server terminated early with status 127 
Shell :: docker pull adguard home 
Shell :: git list last marge 
Shell :: how to copy one file to multiple directories in linux 
Shell :: commandAndExit cts 
Shell :: linux scheduled shutdown 
Shell :: ansible tar with a datestamp 
Shell :: rsync kill 
Shell :: git cli 
Shell :: linode attach volume to disk 
Shell :: Could not execute because the application was not found or a compatible .NET SDK is not installed. 
Shell :: remote: Permission to lokeshr001/MotoChatPlugin.git denied to Lokesh003Coding. 
Shell :: allow user to run any command ubuntu 
Shell :: push the branch with the correct name, and reset the upstream branch 
Shell :: disable logging in linux 
Shell :: how to look for tree in ubuntu 
Shell :: error: failed to init transaction 
Shell :: git add symlink 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =