Sponsored Content
Top Forums Shell Programming and Scripting Recursively cat files in a directory with filename printed first. Post 302719043 by lewk on Monday 22nd of October 2012 03:09:30 AM
Old 10-22-2012
Recursively cat files in a directory with filename printed first.

I want to recursively cat the content of files in a directory e.g.

Code:
find /etc -type f -exec cat {} \;

But I want it to print the file name first and then the content. For example let's say /etc/statetab and /etc/colord.conf will be printed first then I want the output to look something like;

Code:
"/etc/statetab"

#
# A list of paths which should be bind-mounted from a
# partition dedicated to persistent data
#
# See $STATE_LABEL in /etc/sysconfig/readonly-root
#
# Examples: 
#
#   /root
#   /etc/ssh
#   /var/spool/mail
#

"/etc/colord.conf"

# This controls whether we search external volumes for color profiles.
#
# default=true
SearchVolumes=true

# If we should use SANE to add scanner and camera devices.
#
# If this is set to 'true' then a colord-sane process will
# automatically be started by the daemon which watches USB scanner
# devices as they are inserted and removed.
#
# default=true
UseSANE=true

# If we should create a dummy sensor for testing

---------- Post updated at 09:09 AM ---------- Previous update was at 08:59 AM ----------

Ignore this post, I managed to figure out;

Code:
for file in $(find /etc -type f) ; do
    echo " "
    echo "Display content of files in /etc/ directory"
    echo "############START OF FILE#########"
    echo ${file}
    echo " "
    cat ${file}
    echo "##########END OF FILE########"
    echo " "
done

I am getting better at this.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Recursively copy only specific files from a directory tree

Hi I am a shell-script newbie and am looking to synchronize certain files in two directory structures. Both these directory-trees are in CVS and so I dont want the CVS directory to be copied over. I want only .sh and .pl files in each subdirectory under these directory trees to be... (3 Replies)
Discussion started by: sharpsharkrocks
3 Replies

2. Shell Programming and Scripting

delete files recursively in the specified directory

I have to write a shell script which can delete all the files and directories recursively inside the specified directory but should not delete the specified directory. Please some body help me in writing the script. (3 Replies)
Discussion started by: deepthi.s
3 Replies

3. UNIX for Dummies Questions & Answers

cat files from subdirectories output using same filename

Hi, I need to concatenate data files with a .mp extension that are stored in directories by year. I want to keep the same filename as an output for example: for the file name p030.mp, which resides in the following subdirectories: /2000/p030.mp /2001/p030.mp /2002/p030.mp I want to:... (4 Replies)
Discussion started by: cmshreve
4 Replies

4. Shell Programming and Scripting

Problem with script generating files in directory recursively

I have a script which generates recursively some files in folders for a given root folder. I have checks for permissions and it works for all folders except one(i have 777 permission on it). When i try calling the script in problematic folder(problematic folder being root folder), script works as... (2 Replies)
Discussion started by: bb2
2 Replies

5. Solaris

Display the number of files in a directory and recursively in each subdirectory

Display the number of files in a directory and recursively in each subdirectory To look something like below, for example /var 35 /var/tmp 56 /var/adm 46Any ideas how can we do this? Got a sun cluser global mount point which takes ages to mount everytime, need to understand... (5 Replies)
Discussion started by: jakerock
5 Replies

6. Shell Programming and Scripting

Cat files listed in text file and redirect to new directory with same filename

I have a directory that is restricted and I cannot just copy the files need, but I can cat them and redirect them to a new directory. The files all have the date listed in them. If I perform a long listing and grep for the date (150620) I can redirect that output to a text file. Now I need to... (5 Replies)
Discussion started by: trigger467
5 Replies

7. UNIX for Dummies Questions & Answers

Find all files containing string not following symlinks CAT (modified) output content to /filename

This should recursively walk through all dirictories and search for a specified string in all present files, if found output manicured content (eg some regex) with CAT into a specified directory (eg /tmp/) one by one, keeping the original names This is what I have so far, which seems to... (1 Reply)
Discussion started by: lowmaster
1 Replies

8. Shell Programming and Scripting

How to recursively copy directory only for recent files?

I love the -newerct flag for the Cygwin find command on windows. Can I use "/usr/bin/find . -newerct '3 hours ago'" to conditionally copy a directory tree so that only the files in the directory tree that are younger than 3 hours are copied to my destination directory such that the directory... (4 Replies)
Discussion started by: siegfried
4 Replies

9. Shell Programming and Scripting

Find Large Files Recursively From Specific Directory

Hi. I found many scripts in the web of achieving this. But I like to use this one find /EDWH-DMT03 -xdev -size +10000 -exec ls -la {} \;|sort -n -k 5 > LARGE.rst But the problem is, why it still list out files with 89 bytes as the output? Is there anything wrong with the command? My... (7 Replies)
Discussion started by: aimy
7 Replies

10. Shell Programming and Scripting

Copy files recursively to one single directory

I need to copy a complete directory structure into a new location. But I want to have all files copied into one directory and leave out the directory structure. So all files must be placed in one directory. (4 Replies)
Discussion started by: ReneVL
4 Replies
sane-usb(5)						   SANE Scanner Access Now Easy 					       sane-usb(5)

NAME
sane-usb - USB configuration tips for SANE DESCRIPTION
This manual page contains information on how to access scanners with a USB interface. It focusses on two main topics: getting the scanner detected by the operating system kernel and using it with SANE. This page applies to USB most backends and scanners, as they use the generic sanei_usb interface. However, there is one exceptions: USB Scanners supported by the microtek2 backend need a special USB kernel driver, see sane-microtek2(5) for details. QUICK START
This is a short HOWTO-like section. For the full details, read the following sections. The goal of this section is to get the scanner detected by sane-find-scanner(1). Run sane-find-scanner. If it lists your scanner with the correct vendor and product ids, you are done. See section SANE ISSUES for details on how to go on. sane-find-scanner doesn't list your scanner? Does it work as root? If yes, there is a permission issue. See the LIBUSB section for details. Nothing is found even as root? Check that your kernel supports USB and that libusb is installed (see section LIBUSB). USB ACCESS METHODS
For accessing USB devices, the USB library libusb is used. There used to exist another method to access USB devices: the kernel scanner driver. The kernel scanner driver method is deprecated and shouldn't be used anymore. It may be removed from SANE at any time. In Linux, the kernel scanner driver has been removed in the 2.6.* kernel series. Only libusb access is documented in this manual page. LIBUSB
SANE can only use libusb 0.1.6 or newer. It needs to be installed at build-time. Modern Linux distributions and other operating systems come with libusb. Libusb can only access your scanner if it's not claimed by the kernel scanner driver. If you want to use libusb, unload the kernel driver (e.g. rmmod scanner under Linux) or disable the driver when compiling a new kernel. For Linux, your kernel needs support for the USB filesystem (usbfs). For kernels older than 2.4.19, replace "usbfs" with "usbdevfs" because the name has changed. This filesystem must be mounted. That's done automatically at boot time, if /etc/fstab contains a line like this: none /proc/bus/usb usbfs defaults 0 0 The permissions for the device files used by libusb must be adjusted for user access. Otherwise only root can use SANE devices. For Linux, the devices are located in /proc/bus/usb/ or in /dev/bus/usb, if you use udev. There are directories named e.g. "001" (the bus name) con- taining files "001", "002" etc. (the device files). The right device files can be found out by running scanimage -L as root. Setting per- missions with "chmod" is not permanent, however. They will be reset after reboot or replugging the scanner. Usually udev or for older distributions the hotplug utilities are used, which support dynamic setting of access permissions. SANE comes with udev and hotplug scripts in the directory tools/udev and tools/hotplug. They can be used for setting permissions, see /usr/share/doc/packages/sane-backends/README.linux, tools/README and the README in the tools/hotplug directory for more details. For the BSDs, the device files used by libusb are named /dev/ugen*. Use chmod to apply appropriate permissions. SANE ISSUES
This section assumes that your scanner is detected by sane-find-scanner. It doesn't make sense to go on, if this is not the case. While sane-find-scanner is able to detect any USB scanner, actual scanning will only work if the scanner is supported by a SANE backend. Informa- tion on the level of support can be found on the SANE webpage (http://www.sane-project.org/), and the individual backend manpages. Most backends can detect USB scanners automatically using "usb" configuration file lines. This method allows to identify scanners by the USB vendor and product numbers. The syntax for specifying a scanner this way is: usb VENDOR PRODUCT where VENDOR is the USB vendor id, and PRODUCT is the USB product id of the scanner. Both ids are non-negative integer numbers in decimal or hexadecimal format. The correct values for these fields can be found by running sane-find-scanner, looking into the syslog (e.g., /var/log/messages) or under Linux by issuing the command "cat /proc/bus/usb/devices". This is an example of a config file line: usb 0x055f 0x0006 would have the effect that all USB devices in the system with a vendor id of 0x55f and a product id of 0x0006 would be probed and recog- nized by the backend. If your scanner is not detected automatically, it may be necessary to edit the appropriate backend configuration file before using SANE for the first time. For a detailed description of each backend's configuration file, please refer to the relevant backend manual page (e.g. sane-mustek_usb(5) for Mustek USB scanners). Do not create a symlink from /dev/scanner to the USB device because this link is used by the SCSI backends. The scanner may be confused if it receives SCSI commands. ENVIRONMENT
SANE_DEBUG_SANEI_USB If the library was compiled with debug support enabled, this environment variable controls the debug level for the USB I/O subsys- tem. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. Values greater than 4 enable libusb debugging (if available). Example: export SANE_DEBUG_SANEI_USB=4. SEE ALSO
sane(7), sane-find-scanner(1), sane-"backendname"(5), sane-scsi(5) AUTHOR
Henning Meier-Geinitz <henning@meier-geinitz.de> 14 Jul 2008 sane-usb(5)
All times are GMT -4. The time now is 11:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy