Answer the question
In order to leave comments, you need to log in
I can't get the script to work with IF, what could be the reason?
Hello. I got a task, not difficult, but never dealt with programming even close. That's why help is needed.
You need to write a script that will display the top 10 files by size from the selected directory.
#!/bin/bash
dir=$1
dir2=$2
if ; then find $2 -type f -ls 2> /dev/null | sort -rnk7 | head -10 | awk '{printf "%10d MB\t%s\n",($7/1024)/1024,$NF}'
fi
if ; then echo "help me"
fi
if ; then echo "No args"
fi
Answer the question
In order to leave comments, you need to log in
#!/usr/bin/env bash
if [ "$#" -gt "1" ]
then
echo "To many arguments"
exit 1
fi
if [ -z "$1" ]
then
echo "Введите директорию!"
exit 1
fi
if
then
find "$1" -type f -ls 2> /dev/null | sort -rnk7 | head -10 | awk '{printf "%10d MB\t%s\n",($7/1024)/1024,$NF}'
elif
then
echo "Help me!"
else
echo "$1 не директория!"
fi
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question