Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
You will create a shell script that performs the following action:
Use a parameter to pass a file that contains a list of file locations.
Read the list of file locations and store it as a variable
Using the list of file location create a compressed file, do not show any output from this command
Display the contents of the compressed file
Display the size of the newly created compressed file
Keep getting the following errors/outputs:
tar: Removing leading `/' from member names
tar: /phager/Desktop: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
The script still creates the compression file, but when I try to display the file size and file name with the stat command I get more info than I want, all I need to display is the file size and name after the echo command "The size of file1.tgz is:"
2. Relevant commands, code, scripts, algorithms:
3. The attempts at a solution (include all code and scripts):
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Leeward Community College, Pearl City, HI, USA, Peter Gross, ICS240, https://www.sis.hawaii.edu/uhdad/ava...201610&c=55462
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
You seem to be confused about how you reference parameters passed to a shell script, about how the variable name passed to and filled in by the shell's read built-n works, and about how to reference variables created in your shell script.
I would suggest re-reading the manual page for bash on your system (using the command: man bash) paying special attention to the discussion in the PARAMETERS section, in the EXPANSION section, and the description of the read utility in the SHELL BUILTIN COMMANDS section.
If you have a file named list_of_files containing:
and the script:
in a file named readlist which you have made executable with the command:
then see what happens when you run the command:
Does this help?
.
.
.
Keep getting the following errors/outputs:
tar: Removing leading `/' from member names
tar: /phager/Desktop: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
The first tar line is invormative. The rest should be self- explaining, no?
Quote:
The script still creates the compression file, but when I try to display the file size and file name with the stat command I get more info than I want, all I need to display is the file size and name after the echo command "The size of file1.tgz is:"
.
.
.
That will be an empty file - not empty, but just binary zeroes. How about man stat?
can be understood as redirecting any 'error message' to /dev/zero.
Like:
Alternativly, you could redirect and appending (the double >>) to a logfile like:
hth
can be understood as redirecting any 'error message' to /dev/zero.
Like:
... ... ...
Although /dev/zero can be used this way on most systems, the conventional device for dumping output into the trash can is /dev/null which is described by the standards as:
The standards do not require systems to provide /dev/zero.
This User Gave Thanks to Don Cragun For This Post:
Hello Unix Shell Script Experts,
I have a script that would mask the columns in .csv file or .txt file.
First the script will untar the .zip files from Archive folder and processes into work folder and finally pushes the masked .csv files into Feed folder.
Two parameters are passed
... (5 Replies)
Need assistance in getting a solution for a TCSH shell environment variable .
I read on internet that leading zeros as octal numbers and redhat doesnt supports octals but Solaris works on TCSH shell. Is there any way we can fix this . All my script has 08 or 09
$ @ x = 5 + 08
@: Badly formed... (8 Replies)
I have below files in foler one/archive>
one. txt 6/21/2013
two txt 7/23/2013
three.txt 6/20/2013
I wanted to move all the old files (>30 days) compressing single .zip file into one/archive/ as below
two txt 7/23/2013
oldfiles.zip 6/21/2013
Please provide... (6 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
2. Shell Bash Script
3.
!/bin/bash
if
echo no directory
then
mkdir -p /home/AC_Drywall
elif ; then
echo "$dir already exist"
fi (4 Replies)
Hi,
Is there any way to change the file name while compressing ? using Compress and gzip and tar ?
Say, I have a file foo.txt - so I have to compress this file and the resultant file name is foo.txt_20130113.gz or foo.txt_20130113.Z
This to be done while performing the compression... (2 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I am working on a hands on project. We are creating a script for a corporate phone list. The project I am... (2 Replies)
i need to backup a directory from one partition to another and and compress that directory after backing up, so i need to predict the compressed size of the directory with out actually compressing it, to check whether the space is available in the destination partition to accommodate the zipped... (2 Replies)
Hello All
Posted a similar thread in some other section too. Regrets if this section is not suitable for this post. Request all the members to be tolerant as i'm a newbie here :)
Coming to the topic : I've this huge log files of size 20GB-30 GB in my unix server. I want to analyse the log... (2 Replies)
Hi,
I'm a newbie to UNIX scripting and I'm having some trouble compiling my script. I'm using the Bourne Shell and cannot seem to use the substr function correctly. I'm trying to extract the last two digits of a year that's stored in a variable based off of a condition. I've searched the... (4 Replies)
Hi, i have written a script in unix which produces two files(.csv file) at the end. Now i want to add these to files in a zip file and send the zip file across the network by FTP.
Problem is that i dunno how to make a single zip file containing the two files that have been created by the script.... (1 Reply)