Hi ,
Am trying to gunzip a file and pass the gunzipped file name to a variable , but its not taking up the value. Am trying to execute the command f=`gunzip <filename>`;echo $f. Here the file is getting gunzipped but the file name is not assigned to the variable. Any help on this will be useful. Am trying to rename the gunzipped file to a specific format .
Thanks.
gunzip does not write anything to stdout that could be assign to the variable f. If you just want to assign the filename without the .gz suffix to f, write:
If you need to control the filename of the uncompressed file, you can have gunzip write to a redirected standard output.
You might also be interested in the uncompressed filename displayed by -l. But, I don't know since your goal is a mystery.
If you need further help, why don't you show us the entire script, and explain what it is you are trying to accomplish.
Regards,
Alister
Hi,
Thanks for the reply. This is the part of the code gunzip /tmp/$b where $b is having the zipped file name. I just want the file name to be gunzipped and the filename should be renamed to other format. So retrieving only the zipped filename will be useful
If you have the filename in $b, then what's the problem?
Not knowing more about the filename and what guarantees are in place regarding its suffix, nor knowing what you are trying to accomplish, I can't confidently suggest how to proceed.
If the suffix is recognized by gunzip, it will automatically strip the suffix when it decompresses the file. If the suffix is not recognized by gunzip, it will not work on the file. If you attempt to modify the filename in your shell variable independently of the renaming that gunzip may or may not perform, disagreement could ensue if error conditions aren't checked and handled diligently.
If you simply need the name of the decompressed file so that you can work with it, you may be better off handling all file renaming yourself and explicitly instructing gunzip what to name your file:
...where newname is something under your control.
If this isn't of any help to you, then, please, for the second time, just share your code. Your textual explanations so far have been inadequate. I'm not sure anyone understands the problem or the goal.
I have a below syntax its working fine...
var12=$(ps -ef | grep apache | awk '{print $2,$4}')
Im getting expected output as below:
printf "%b\n" "${VAR12}"
dell 123
dell 456
dell 457
Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
I have a small program which needs to pass variable dynamically to form the name of a second variable whose value wil be passed on to a third variable.
***************** Program Start ******************
LOC1=/loc1
PAT1IN=/loc2
PAT2IN=/loc3
if ; then
for fpattern in `cat... (5 Replies)
Hi all,
I am executing shell script in which I am using SQLLDR
In this SQLLDR I am passing text file having PL/SQL script. This script will produce some formated output, this output I have to spool in another text file. Currently I have given this in script file as following
Spool... (2 Replies)
Hi All,
Its extremely urgent regarding the following requirement.
I have created few files in a directory. I have write a program in shell scripting such that it prompts for the filename . once the filename is entered,it should print the contents of the file.
Can anyone help with... (7 Replies)
Hello, i'm fairly new to scripting, so please bear with me (I did try looking this up first, i figured it had to have been asked already).
#!/bin/bash
fileName=`date | sed -n 's/ /_/g p' | sed -n 's/^/Backup_/p' | sed -n 's/$/\.tar/p'`; #THIS SETS BACKUP_DATE
echo $fileName #TEST OF VALUE
... (4 Replies)
Any help would be great. I know this is a dumb way of doing this, but I would like to know if there is a solution doing it this way. I'm very new at this and I'd like to learn more. Thanks! :D:D
count=0
while ; do
echo "enter your name"
read name_$count
let count=count+1
done
... (2 Replies)
Hi,
I have a requirement to write a script file(script1.sh) to read the file from the folder say /usr1/profiles/active and pass the file name as a parameter to another script file say (script2.sh) which would subsitute this parameter.
The script2.sh will have a line like the one below
... (1 Reply)
Anyone who can assist :
I am trying to pass the group vairiable to a filename:
rpt_tsavegrp=/export/legato/scripts/$group_savegrp_rpt.$dat
It will not pass to variable.
Anyone have any ideas what I am doing wrong here.
Thanks
# This script sends email that save group completed.... (3 Replies)
I would like to know how to pass a variable inside a variable to a function.
sample code below
--------------
for x in 1 9
do
check_null $C$x ##call function to check if the value is null
if
then
echo "line number:$var_cnt,... (2 Replies)