1

I want to remove the dot from the display with a awk command but don't know how ?

My code

#!/bin/bash
cd /home/jeremy
touch home_pers_taille.txt
date>>home_pers_taille.txt
du -sh>>home_pers_taille.txt

cat home_pers_taille.txt

the dispaly

enter image description here

2
  • 2
    Some advice -- try not to cd from within your scripts ( cd /home/jeremy ) .. It can have unintended results based on the user executing etc .. Instead try to use absolute paths within forked commands .. ( touch /home/jeremy/home_pers_taille.txt ) OR store your directory in a variable and use it in your absolute path, if you find typing it out every time is cumbersome. ( touch $my_dir/home_pers_taille.txt ) Commented May 4, 2021 at 23:19
  • 1
    du -sh | awk '{print $1}' Commented May 4, 2021 at 23:32

1 Answer 1

4

No need for awk, this is the kind of job cut exists to do:

$ du -sh
16K     .

$ du -sh | cut -f1
16K
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.