How to supress the file name when we check for disk space ?
I used this command :
du -ks /home/dir1/dir2/file.csv
it returns
13 /home/dir1/dir2/file.csv
Please explain the options too
How to supress the file name when we check for disk space ?
I used this command :
du -ks /home/dir1/dir2/file.csv
it returns
13 /home/dir1/dir2/file.csv
Please explain the options too
You may use this:
du <filename> | awk '{print $1}'
Thank you. I am wondering du command executing in the command line.
But when i gave the same command in .sh file. it is giving
du: cannot access /user/dir1/dir2/file1\r : No such file or directory
i wonder how "\r" comes at the end. Please provide a solution
Please post the output of cat -A <script_file>
. This should be the common carriage return problem faced when porting files created on windows to unix.
du -sk /user/dir1/dir2/file1 -> its working
path="/user/dir1/dir2/file1"
du -sk $path -> working
path=`head -1 export1.tsv | awk '{ print $5 }'`
du -sk $path - Not working
cat export.tsv
24-JAN-12 24-JAN-12 "fsjkf" "khfsjf_X" "/user/dir1/dir2/file1"
---------- Post updated at 02:55 AM ---------- Previous update was at 02:34 AM ----------
I found that the export1.tsv file contain ctrl+M character.. How to remove it.. I used sed command to remove the ctrl M , When i try to press control M , it take it as enter and leave from command ..
host:/auto/dir/pf88833/scripts> sed 's/
Unmatched '.
hi,
you can remove the ctrl+M character by running the following command on file
dos2unix export.tsv export.tsv
thanks,
venkat
Moderator comment: Syntax should be:
dos2unix export.tsv > export_new.tsv
# Or if you have the command under the new name
dos2ux export.tsv > export_new.tsv
@arukuku: There're lots of posts on how to remove the end of line control character. Check this post : www.unix.com/shell-programming-scripting/175130-unix-problem-new-line-character.html
And, try this:
path=`head -1 export1.tsv | awk '{ print $5 }' | tr -d '"'`
du -sk $path
Combining all the above ideas: Getting rid if the MSDOS carriage-return character, removing the double quotes, and outputting only the total from "du".
path=`head -1 export.tsv | awk '{print $5}' | tr -d '\r"'`
du -sk ${path} | awk '{print $1}'