Du command not able to read file.


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Du command not able to read file.
# 1  
Old 08-21-2018
Du command not able to read file.

hi
when i am trying to check the file size using du command in shell script but getting a below error, although the file is present
Code:
du: cannot access `LOGS_18-08-20.tar.gz': No such file or directory

below is snippet of script
Code:
cd /home
dt=$(date --date="yesterday" +"%y-%m-%d")
du  "LOGS_$dt.tar.gz"


Last edited by scriptor; 08-21-2018 at 05:11 AM.. Reason: typo error
# 2  
Old 08-21-2018
Quote:
Originally Posted by scriptor
hi
when i am trying to check the file size using du command in shell script but getting a below error, although the file is present
Code:
du: cannot access `LOGS_18-08-20.tar.gz': No such file or directory

below is snippet of script
Code:
cd /home
dt=$(date --date="yesterday" +"%y-%m-%d")
du  "LOGS_$dt.tar.gz"

Is LOGS_18-08-20.tar.gz in /home?
What do you get when you type
Code:
echo /home/LOGS_*.gz

Andrew
# 3  
Old 08-21-2018
hi Andrew
yes file is in /home


this command o/p gives me
Code:
 echo /home/LOGS_*.gz

I get
Code:
 /home/LOGS_2018-08-20.tar.gz


Last edited by scriptor; 08-21-2018 at 06:30 AM.. Reason: tag missed
# 4  
Old 08-21-2018
The file is /home/LOGS_2018-08-20.tar.gz and you are looking for /home/LOGS_18-08-20.tar.gz. Change the %y in your script to %Y and try again.

Andrew
These 2 Users Gave Thanks to apmcd47 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read in txt file and run a different command for each line

hi, i'm trying to write a tcsh script that reads in a text file (one column) and the runs a different command for each line of text. i've found lots of example commands for bash, but not for tcsh. can anyone give me a hint? thanks, jill (8 Replies)
Discussion started by: giuinha
8 Replies

2. Shell Programming and Scripting

Read command restarts at beginning of file

I am reading in a file in a Korn shell script. The file has one header row followed by possibly millions of data rows. I want to do one thing to the header row and write it out to a new output file, then something different to the data rows. My code looks like this: read header < $infile ... (4 Replies)
Discussion started by: DJR
4 Replies

3. Shell Programming and Scripting

Process to read a new file entry and execute a command

I need to develop a process/daemon which will constantly monitor a file for new entry and execute a command. for eg, there is a file /var/log/inotify.log When a new entry like below gets appeneded to this file, execute the command as follows. /home/user/public_html/bad.php|CREATE ... (2 Replies)
Discussion started by: anil510
2 Replies

4. Shell Programming and Scripting

Read file and run a command

Hi I have jobs (some 1000) defined in a file and I want to read those jobs and run a a command. For example: jobs.txt abc efg I want to read the entire file and run the following command Delete -JOB "abc" Deleteing abc... Delete -JOB "efg" Delete efg... Can somebody help me... (4 Replies)
Discussion started by: karan8810
4 Replies

5. Shell Programming and Scripting

Read from file and execute the read command

Hi, I am facing issues with the below: I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,). Now i want to read this command from file and execute it. So my code below is : Contents in the lookup.lkp file is : c_e,m,a,`cd $BOX | ls cef_*|tail... (7 Replies)
Discussion started by: vital_parsley
7 Replies

6. UNIX for Dummies Questions & Answers

Read workstation list from file und run command

Hi, how do I read in a file which includes a list of workstations and then run a command for each workstation ? I am unclear which command to use to read in , or is this not possible ? Thanks, (3 Replies)
Discussion started by: manni2
3 Replies

7. Shell Programming and Scripting

How to read a file name that was recently edited when listed using ls command?

I was trying to write a script that will process recently creatd file. From below, the script should process input_20111230.dat file. sam:/top/work/data/input: ls -ltr input_*.dat -rw-rw-rw- 1 work edprod 455668 Dec 24 09:16 input_20111224.dat -rw-r--r-- 1 work edprod ... (7 Replies)
Discussion started by: siteregsam
7 Replies

8. Shell Programming and Scripting

Environment Variables in text file and read command

I cannot get the following substitution ($ORACLE_SID) to work: The variable ORACLE_SID is set to wardin my environment. It has been exported. I have a text file called test.dat: /u07/oradata/${ORACLE_SID}/extab/finmart/summit/ps_voucher_line_crnt_ex.dbf... (2 Replies)
Discussion started by: bradyd
2 Replies

9. Shell Programming and Scripting

read file column and paste it in command

Hi Unix gurus I have a file containing 2 coloumns. I would like to do a script which reads the lines and executes a command like this: command <field1> parameters <field2> some more parameters Please let me know how you would do this without AWK, SED or any other mini language (for special... (5 Replies)
Discussion started by: BearCheese
5 Replies

10. Shell Programming and Scripting

command to read file name and size

hi all, there is any command or anything we can use to read the file name and size. thanks (6 Replies)
Discussion started by: s_linux
6 Replies
Login or Register to Ask a Question