Sponsored Content
Full Discussion: find + printf help
Top Forums Shell Programming and Scripting find + printf help Post 302468453 by danschmidt on Tuesday 2nd of November 2010 07:11:12 PM
Old 11-02-2010
find + printf help

Hi, I have a scripting assignment for an intro to linux class and I'm really confused about how to do something seemingly simple.

I am supposed to Print the name of each file in the /data/dir16/subdir1 directory in the following format: "My name is: bin"

The desired output example looks like:
My name is: /data/dir16/dir1/testfile1
My name is: /data/dir16/dir1/testfile2
so on...

So first question is, am I on the right track in thinking I am supposed to use the find and printf combination?

Right now, all I've tried is various combinations of find /data/dir16/dir1 printf "My name is:" which just produces 13 instances of "My name is:".

How do I append the filenames to the end of the "My name is" string?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

printf format

hi, i would like to extract the header and put it in a variable, then use printf to output the variable, but i keep on getting errors...please tell me if my format is incorrect. HDR = "`ps -e -o user,pid,ppid,pcpu,stime,etime,time,comm | head -n 1`" printf (%s, $HDR); thanks! (3 Replies)
Discussion started by: laila63
3 Replies

2. Shell Programming and Scripting

find: problems escaping printf-command string

Hi Folks! Can you help me with this find -printf command. I seem to be unable to execute the printf-command from my shell script. I'm confused: :confused: My shell script snippet looks like this: #!/bin/sh .. COMMAND="find ./* -printf '%p %m %s %u %g \n'" echo "Command: ${COMMAND}"... (1 Reply)
Discussion started by: grahamb
1 Replies

3. Programming

printf

What is the output of the following program considering an x86 based parameter passing sequence where stack grows towards lower memory addresses and that arguments are evaluated from right to left: int i=10; int f1() { static int i = 15; printf("f1:%d ", i); return i--; } main() {... (2 Replies)
Discussion started by: arunviswanath
2 Replies

4. Shell Programming and Scripting

printf

How to print output in following format? A..................ok AA................ok AAA..............ok AAAAAA........ok "ok" one under one (4 Replies)
Discussion started by: mirusnet
4 Replies

5. Shell Programming and Scripting

printf / regex

Morning folks, I need help with the following issue: Let's say we I have the following output: First Name: Test Last Name: Test2 Number: T1234 Number2: T1234 Needed Output: T1234 Now I want to grep/nawk/printf/sed out the Number: (13 Replies)
Discussion started by: domi55
13 Replies

6. UNIX for Dummies Questions & Answers

Need help with printf

Hi, I have just completed my first script (:D) and now i just need to format it with printf. This is what I have: #!/bin/ksh TOTB=0 TOTF=0 TOTI=0 HOST=`hostname` echo " FSYSTEM BLKS FREE INUSE MOUNTEDON" df -m | grep -v ":"|grep -v Free|grep -v "/proc"| while read FSYSTEM... (2 Replies)
Discussion started by: compan023
2 Replies

7. UNIX for Dummies Questions & Answers

The meaning of %s in printf

I have this command like that has %s in it, I know %s calls a column, but I am not sure I understand which column (I mean for my case I can check the input file, but I want to know how is this %s used, how comes tha same symbo; gives different columns in one command line: {printf "grep %s... (22 Replies)
Discussion started by: cosmologist
22 Replies

8. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

9. UNIX for Dummies Questions & Answers

Using printf in bash

printf "%5.5\n" "1234567890" will print 12345 . How do I get it to print 67890 Essentially, I just want the last 5 characters rather than the first 5. (4 Replies)
Discussion started by: lavender
4 Replies

10. Shell Programming and Scripting

Need find package that supports printf on AIX

My current find command does not support printf. I need find package that supports printf on AiX 6.1 system. Can anyone help me with the download link or where / how / if I can find it ? Can it be installed at a different non default location so that it can be reference without... (5 Replies)
Discussion started by: mohtashims
5 Replies
showfile(8)						      System Manager's Manual						       showfile(8)

NAME
showfile - displays the attributes of AdvFS directories and files SYNOPSIS
/usr/sbin/showfile [-i] [-h | -x] filename... OPTIONS
Displays the raw extent map for an AdvFS file (including any holes). You cannot use both the -h and the -x options in the same command. When a filename is a directory, displays attributes for the directory's index file. Displays the full storage allocation map (extent map) for AdvFS files. You cannot use both the -h and the -x options in the same command. OPERAND
One or more directory or file names. If you do not supply filename arguments, you can use an asterisk (*) to display all the files in the current directory. DESCRIPTION
The showfile command displays the attributes of one or more AdvFS files. The command also displays the extent map of each file. An extent is a contiguous area of disk space that the file system allocates to a file. Simple files have one extent map; striped files have an extent map for every stripe segment. You can list AdvFS attributes for an individual file or the contents of a directory. Although the showfile command lists both AdvFS and non-AdvFS files, the command displays meaningful information for AdvFS files only. The showfile command displays the following file attributes: Id The unique number (in hexadecimal format) that identifies the file. Digits to the left of the dot (.) character are equivalent to a UFS inode. Vol The location of primary metadata for the file, expressed as a number. The data extents of the file can reside on another volume. PgSz The page size in 512-byte blocks Pages The number of pages allocated to the file XtntType The extent type can be simple, which is a regular AdvFS file without special extents; stripe, which is a striped file; symlink, which is a symbolic link to a file; ufs, nfsv3, and so on. The showfile command cannot display attributes for either symbolic links or non-AdvFS files Segs The number of stripe segments per striped file, which is the number of volumes a striped file crosses. (Applies only to stripe type.) SegSz The number of pages per stripe segment. (Applies only to stripe type.) I/O The type of write requests to this file. Write requests are buffered (the AdvFS default) Forced synchronous writes as described in chfile(8) Write requests executed under AdvFS transaction control, which is reserved for metadata files and directories. Perf The efficiency of file-extent allocation, expressed as a percentage of the optimal extent layout. A high percentage, such as 100%, indicates that the AdvFS I/O system has achieved optimal efficiency. A low percentage indicates the need for file defragmentation. File The name of the directory or file. If the file is a directory that has an index file associated with it and the -i option has not been specified, the statistics displayed are for the directory. The term index follows the directory name. If the file is a direc- tory that has an index file associated with it and the -i option is specified, the statistics displayed are for the index file asso- ciated with the directory. The name of the directory follows the index. Whereas a simple file has one extent map, a striped file has more than one extent map. An extent map (numbered extentMap:1, extentMap:2, and so on) displays the following information: pageOff The starting page number of the extent pageCnt The number of pages in the extent vol The location of the extent, expressed as a number volBlock The starting block number of the extent blockCnt The number of blocks in the extent extentCnt The number of extents EXAMPLES
The following example displays the AdvFS-specific attributes for all the files in the current working directory: # showfile * Id Vol PgSz Pages XtntType Segs SegSz I/O Perf File 6.8001 1 16 427 simple ** ** async 100% datafile1 7.8001 1 16 427 simple ** ** sync 100% datafile2 5.8001 1 16 1 simple ** ** ftx 100% quota.group 4.8001 1 16 1 sim- ple ** ** ftx 100% quota.user The following example displays the attributes for a directory named dir1 and then displays the attributes for an index file for the dir1 directory: # showfile dir1 Id Vol PgSz Pages XtntType Segs SegSz I/O Perf File 7b.8001 1 16 48 simple ** ** ftx 13% dir1 (index) # showfile -i dir1 Id Vol PgSz Pages XtntType Segs SegSz I/O Perf File 5511.8001 1 16 43 simple ** ** ftx 15% index (dir1) The following example shows the attributes and extent information for the mail file, which is a simple file: # showfile -x mail Id Vol PgSz Pages XtntType Segs SegSz I/O Perf File 4198.800d 2 16 27 simple ** ** async 66% tutor extentMap: 1 pageOff pageCnt vol volBlock blockCnt 0 5 2 781552 80 5 12 2 785776 192 17 10 2 786800 160 extentCnt: 3 SEE ALSO
advfs(4) showfile(8)
All times are GMT -4. The time now is 04:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy