Sponsored Content
Top Forums Shell Programming and Scripting Foreach .gz file in a directory -- Not working Post 302898982 by IB_88 on Friday 25th of April 2014 10:03:44 AM
Old 04-25-2014
Foreach .gz file in a directory -- Not working

Hi,

I am trying to add for loop in my code for all the .gz files in a directory.

example code:

Code:
for i in $PWD/input/*.dz
do
     echo " file is :: $i "
done

This is not working as expectation and the output is :
Code:
 file is :: /home/IB/input/*.dz



However, for i in $PWD/input/* is working fine. But this is not the requirement.
Please suggest

Moderator's Comments:
Mod Comment Use code tags, thanks.
 

9 More Discussions You Might Find Interesting

1. Programming

Getting present working directory

How can I get the present working directory in unix system using c programming and stored it in a string ?? (0 Replies)
Discussion started by: winsonlee
0 Replies

2. UNIX for Dummies Questions & Answers

working directory shown

Hi, How do I get my working directory always shown in the unix editor? i.e if I am now at /Home/abc/xyz/, I want to see this absolute path displayed ( and now only display when I type pwd). thanks for the kind help. Regrads (3 Replies)
Discussion started by: swchee
3 Replies

3. HP-UX

how could I get process working directory

how could I use c program to get HP UX process working directory (1 Reply)
Discussion started by: alert0919
1 Replies

4. Shell Programming and Scripting

Shell script: foreach file -> targzip

Hi there, I need some help with a shell script (I'm no sh script expert, but I hope this will explain how I want my script):dir = /home/user/files/ foreach(*.jpg file in $dir) { tar -cf $file(-.jpg).tar $file;gzip $file(-.jpg).tar } mv -f $dir*tar.gz /home/user/pictures/ Thanks for any... (12 Replies)
Discussion started by: JKMlol
12 Replies

5. Shell Programming and Scripting

put working directory in file

how to put pwd in my file my working directory is /usr/my_dir below my file aaaaaa bbbbbb so output file become /usr/my_dir aaaaaa bbbbbb (2 Replies)
Discussion started by: zulabc
2 Replies

6. Shell Programming and Scripting

foreach loop working in terminal but not in the script

Hi, I am new here I have used the forums a long time to search for things they are very helpful. I have unfortunately used up all my resources (professors, grad students) and need some help. I have this very simple piece of code (using to isolate the problem) in a csh script: #!/bin/csh... (12 Replies)
Discussion started by: bflinchum
12 Replies

7. UNIX for Dummies Questions & Answers

Foreach loop that skips the header line of a file (csh)

Hello all, I'm working on a foreach loop to compare a couple sets of data. However, each datafile includes a header row. I'm wondering if it is possible to tell the foreach loop to skip the first line of data. I've been using the basic code as follows: foreach line ("`file.csv`") set... (2 Replies)
Discussion started by: meteorologistks
2 Replies

8. Shell Programming and Scripting

PERL foreach & open not working together

My script is as below: my $tile_list = `egrep "FCFP_TILE_LIST.*=" ${BudgetDir}/tile.params | sed -e 's/FCFP_TILE_LIST//' | sed -e 's/=//'`; print "Tile List = ".$tile_list."\n"; my @tiles = split(/\s+/, $tile_list); $unconst_out = "${DestDir}/Unconstrained_ports.rpt"; $check_tim_out =... (2 Replies)
Discussion started by: kuchi7
2 Replies

9. UNIX for Dummies Questions & Answers

Reading foreach variable from a text file

Hello, I have a text file named "foreach.txt" which reads like --- foreach cal ( 1 2 3 4 5 ) I am using a simple script which looks like --- #!/bin/tcsh foreach cal (1 2 3 4 5) echo "$cal" end Is it possible to modify the script in such a way that instead of writing foreach cal (1... (6 Replies)
Discussion started by: Indra2011
6 Replies
break(1)							   User Commands							  break(1)

NAME
break, continue - shell built-in functions to escape from or advance within a controlling while, for, foreach, or until loop SYNOPSIS
sh break [n] continue [n] csh break continue ksh *break [n] *continue [n] DESCRIPTION
sh The break utility exits from the enclosing for or while loop, if any. If n is specified, break n levels. The continue utility resumes the next iteration of the enclosing for or while loop. If n is specified, resume at the n-th enclosing loop. csh The break utility resumes execution after the end of the nearest enclosing foreach or while loop. The remaining commands on the current line are executed. This allows multilevel breaks to be written as a list of break commands, all on one line. The continue utility continues execution of the next iteration of the nearest enclosing while or foreach loop. ksh The break utility exits from the enclosed for, while, until, or select loop, if any. If n is specified, then break n levels. If n is greater than the number of enclosing loops, the outermost enclosing loop shall be exited. The continue utility resumes the next iteration of the enclosed for, while, until, or select loop. If n is specified then resume at the n- th enclosed loop. If n is greater than the number of enclosing loops, the outermost enclosing loop shall be used. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words that follow a command preceded by ** that are in the format of a variable assignment are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign, and also that word splitting and file name genera- tion are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), exit(1), ksh(1), sh( 1), attributes(5) SunOS 5.10 17 Jul 2002 break(1)
All times are GMT -4. The time now is 09:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy