Sponsored Content
Top Forums Shell Programming and Scripting Howto Print File Path or Print the Filename Post 302360411 by overkill on Thursday 8th of October 2009 11:28:41 PM
Old 10-09-2009
Howto Print File Path or Print the Filename

I'm trying to clean up my samba share and need to print the found file or print the path of the image it tried to searched for. So far I have this but can't seem to get the logic right. Can anyone help point me in the right direction?

Code:
 
for FILE in `cat list`; do
     if [ ! -z `find /opt -name $FILE` ];
     then
          echo "File $FILE does not exists"
     else
          echo "$FILE exists"
     fi
done


Last edited by zaxxon; 10-09-2009 at 01:51 AM.. Reason: code tags and indention
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl: howto print to screen & filehandle

Hello, I need to print messages both to screen and to file handle in perl , like tee does in unix . Any suggestions ? Thanks (2 Replies)
Discussion started by: Alalush
2 Replies

2. Shell Programming and Scripting

print the filename

#!/bin/ksh for files in `ls *.gz` do gunzip -c $files | awk -v s=$files -F\" '{print s","$6}' done I have tried FILENAME parameter but it did not work please help. (1 Reply)
Discussion started by: harshakirans
1 Replies

3. UNIX for Dummies Questions & Answers

find locked files, print file path, unlock file

using OS X and the Terminal, I'd like to find all locked files in a specified directory, unlock them, and print a list of those files that were unlocked how can I do this? I'm familiar with chflags nouchg for unlocking one file but not familiar with unix enough to do what I'd like. Thanks! (0 Replies)
Discussion started by: alternapop
0 Replies

4. Shell Programming and Scripting

awk print: howto single quote not interpreted!?

cat a | awk -F";" '{print "update db set column=' "$2" ' where column1=\""$1"\";"}' > ip-add.sql Hi! I'm a new user! i need to use single quote in the double quotes print string The apex between che "$2" should not be interpreted, but....how?! I'm trying to use \ but don't work correctly! ... (4 Replies)
Discussion started by: Re DeL SiLeNziO
4 Replies

5. Shell Programming and Scripting

Print only Filename based on given String on file name

Hi, I am new to this unix world. Any ways, I would like to write a shell script that can print the file name. Ex : directory will have 5 files with different name.No matter what are contents are. Now I need to find the file which will have particular name (sub string ).Please do not... (5 Replies)
Discussion started by: akb2010
5 Replies

6. Shell Programming and Scripting

Print filename with awk

I can got the filename with this script. it's only show "-" in result. cut -d , -f7 CSV_d.* | awk 'OFS=":"{print FILENAME,substr($1,1,8),substr($1,9,2),substr($1,11,2),substr($1,13,2)}' | sort |uniq (2 Replies)
Discussion started by: before4
2 Replies

7. Shell Programming and Scripting

print all filenames in directory with path to another file

hi, i have a directory at /path/unix with the following files 1.txt 2.txt 3.txt 4.txt I want to make another file called filenames.txt at a different location called /path/home. So, my output file would be /path/home/filenames.txt with contents /path/unix/1.txt... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

8. Shell Programming and Scripting

Use while loop to read file and use ${file} for both filename input into awk and as string to print

I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix. I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice. Files:... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

9. Linux

How to print full path name along with file extension?

Hi I have a requirement like this: /abc/a/x.txt /abc/a/y.txt /abc/b/x.gz /abc/b/y.txt I need output like this: /abc/a:*.txt /abc/b:*.txt /abc/b:*.gz I have tried find /abc -type f -name "*.*" ||awk -F . '{print $NF}' it is print only extensions without path name. Please... (5 Replies)
Discussion started by: lijjumathew
5 Replies

10. Shell Programming and Scripting

How to print contents of file when the file path is in a variable?

The file f1 contains the text "body" (shell prompt is "$"): $ cat ~/path/f1 body How to print contents of f1 when the f1 path is in a variable? Here is my failed attempt: $ f1="~/path/f1" $ echo $f1 ~/path/f1 $ cat $f1 cat: '~/path/f1': No such file or directory (2 Replies)
Discussion started by: wolfv
2 Replies
MINCINFO(1)							 MINC User's Guide						       MINCINFO(1)

NAME
mincinfo - print out specified information about a minc file SYNOPSIS
mincinfo [<options>] <file> [<file> ...] DESCRIPTION
mincinfo will print out either a general description of a minc file (type, sign and range of data, plus a brief description of dimensions and their order), or specific information about dimensions, variables or attributes in the file. This program can be very useful for build- ing shell scripts that access minc files. All information given by mincinfo is presented as read from the file with no transformation. This means that start and step values, for example, are not in the world coordinate system. To display the start values for a file in world coordinates, use voxeltoworld. OPTIONS
Note that options can be specified in abbreviated form (as long as they are unique) and can be given anywhere on the command line. Dimen- sions, variables and attributes are all specified by name. Attributes are specified by variable:attribute where variable can be omitted to specify global attributes. More than one option can be specified, in which case the return value from each option is printed on a separate line (-image_info prints on many lines) in the order of the options on the command line. -image_info Print out the default general information about the file. This information includes the type, sign and range of the pixel data, the order of the dimensions, and a list of dimensions giving name, length, start and step for each one. -dimnames Print out a space-separated list of the dimensions in the file. -varnames Print out a space-separated list of the variables in the file. -dimlength dimension Print the length of the specified dimension. -vartype variable Print the type of the variable. -vardims variable Print a space-separated list of the dimensions that subscript the variable (in C order). -varatts variable Print a space-separated list of the attribute names for the specified variable. -varvalues variable Print a newline-separated list of the values of the specified variable. -atttype variable:attribute Print out the type of the specified attribute. -attvalue variable:attribute Print out a space-separated list of the values of the specified attribute. -error_string string Specifies a string to print out if an error occurs. This will cause the program to exit with normal status. The default is to print an appropriate error message and exit with an error status. -help Print summary of command-line options and abort. -version Print the program's version number and exit. EXAMPLES
Print out standard information about a minc file. mincinfo file.mnc Print out contents of global history attribute. mincinfo file.mnc -attvalue :history Print out step value for x dimension, setting the default value to 1. mincinfo file.mnc -attvalue xspace:step -error 1 Print out the step values for x, y and z, setting the default value to 1. mincinfo file.mnc -error 1 -attvalue xspace:step -attvalue yspace:step -attvalue zspace:step Print out the names of the dimensions subscripting the image variable. mincinfo file.mnc -vardims image AUTHOR
Peter Neelin COPYRIGHTS
Copyright (C) 1993 by Peter Neelin SEE ALSO
voxeltoworld(1) $Date: 2004-05-20 21:52:08 $ MINCINFO(1)
All times are GMT -4. The time now is 02:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy