Sponsored Content
Top Forums Shell Programming and Scripting Apply argument to all files in directory Post 302875753 by gpk_newbie on Wednesday 20th of November 2013 10:14:47 AM
Old 11-20-2013
first do an "ls" on the files in the directory which u need to check the head.

Then loop the file names

Code:
#!/bin/bash
cd input_directory
ls -ltr | awk '{print $9}' | sed '/^$/d' > result.txt
while read line
do
head -200 $line >> output_file
done < result.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Apply transformation logic in 2 different files

:)Transformation logic on column values in two different files, File A 12345,000,4444, HKD3.5 12346,000,5555, HKD3.5 File B 12345,4444,54321,6666 12346,5555, 64321,7777 12347,5555, 65321,8888 Requirement as below 1.read file A 2. match with File B ie if (fileA.column1... (1 Reply)
Discussion started by: HAA
1 Replies

2. UNIX for Dummies Questions & Answers

Let GID apply to new files in directory

Hi, Does anyone know if it is possible to override the GID which files have when they are created in a specific folder? I want the given GID for the folder to apply to the new files created in the folder, no matter what group the owner of the files have... I have tried sticky bits but doesn't... (1 Reply)
Discussion started by: linge
1 Replies

3. Shell Programming and Scripting

Apply `chmod` for multiple files through FTP

Hi all, Can you please help me in this aspect. I devoloped a FTP script to copy a directory to remote server. Now i got stuck-up in changing the file permissions for all the files in directory. I tried to change the permissions of single file and I did it but failed in changing... (3 Replies)
Discussion started by: Chanakya.m
3 Replies

4. Shell Programming and Scripting

How to apply a regular expression in all the files in a directory

I have say 100 text files (with .txt extension) in a directory. An example of the content in the file is given below "NAME" "cgd1_200" "cgd1_3210" "cgd1_560" "cgd2_2760" "cgd2_290" "cgd3_3210" "cgd3_3310" "cgd3_660" "cgd5_2130" "cgd5_4080" "cgd6_3690" "cgd6_4480" "cgd8_1540"... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

5. Shell Programming and Scripting

Apply 'awk' to all files in a directory or individual files from a command line

Hi All, I am using the awk command to replace ',' by '\t' (tabs) in a csv file. I would like to apply this to all .csv files in a directory and create .txt files with the tabs. How would I do this in a script? I have the following script called "csvtabs": awk 'BEGIN { FS... (4 Replies)
Discussion started by: ScKaSx
4 Replies

6. Shell Programming and Scripting

apply record separator to multiple files within a directory using awk

Hi, I have a bunch of records within a directory where each one has this form: (example file1) 1 2 50 90 80 90 43512 98 0909 79869 -9 7878 33222 8787 9090 89898 7878 8989 7878 6767 89 89 78676 9898 000 7878 5656 5454 5454 and i want for all of these files to be... (3 Replies)
Discussion started by: amarn
3 Replies

7. Shell Programming and Scripting

help using find/xargs to apply mp3gain to files

I need to apply mp3gain (album mode) to all mp3 files in a given directory. Each album is in its own directory under /media/data/music/albums for example: /media/data/music/albums/foo /media/data/music/albums/bar /media/data/music/albums/more What needs to happen is: cd... (4 Replies)
Discussion started by: audiophile
4 Replies

8. Cybersecurity

Apply SeLinux policy to *nix device files

If its possible to apply SELinux policies to unix device files, would that be a problem? I would like to apply a policy to a process and enforce what it can communicate with device-wise (eg. physical network interface port) based on that policy. Would think that the "selinux-policy-mls" tool... (0 Replies)
Discussion started by: NYG71
0 Replies

9. Shell Programming and Scripting

awk to match and apply condtions to matchijng files in directories

I am trying to merge the below awk, which compares two files looking for a match in $2 and then prints the line if two conditions are meet. awk awk 'FNR==NR{A=$0;next} ($2 in A){if($10>30 && $11>49){print A}}' F113.txt F113_tvc.bed This code was improved and provided by @RavinderSingh13,... (18 Replies)
Discussion started by: cmccabe
18 Replies

10. Shell Programming and Scripting

Apply command to all files in folder

Hi all! I have this command grep -E '^\To: |^\Date: |^\Subject: ' fileA.txt > fileA_1.txt && grep -v '^\To: |^\Date: |^\Subject: ' fileA.txt >> fileA_1.txt && rm fileA.txt && sed -i -e 's/\(Date: \|Subject: \|To: \)//g' fileA_1.txtHow do I apply it to all the files in the folder (each file has a... (7 Replies)
Discussion started by: guilliber
7 Replies
ESCPUTIL(1)						      Gutenprint Manual Pages						       ESCPUTIL(1)

NAME
escputil - maintain Epson Stylus inkjet printers SYNOPSIS
escputil [ -P printer | -r device ] [ -m model ] [ -u ] [ -c | -n | -a | -i | -d | -o | -s | -l | -M | -h ] [ -q ] DESCRIPTION
escputil is a command line utility to perform various maintenance tasks on Epson Stylus inkjet printers. These tasks include head align- ment, head cleaning, nozzle check, printer identification, and retrieval of ink level from the printer. OPTIONS
escputil accepts the following options: -P, --printer-name=printer Specify the name of the printer to operate on. The default is the default system printer. -r, --raw-device=device Specify the name of the device to write to directly rather than going through a printer queue. You must use this (rather than speci- fying a printer) when retrieving ink levels or identifying the printer, or if you wish to perform head alignment without specifying the printer model. -m, --model=model Specify the precise printer model for head alignment. -u, --new The printer is a new printer (Stylus Color 740 or newer). -c, --clean-head Clean the print head. This can also be performed from the printer front panel. -n, --nozzle-check Print a nozzle test pattern. Dirty or clogged nozzles will show as gaps in the pattern. If you see any gaps, you should run a head cleaning pass or two. -a, --align-head Align the print head. CAUTION: Misuse of this option may result in poor print quality and/or damage to the printer. You must either specify the printer model with the -m option, or use the raw printer device to allow escputil to detect the printer model. -i, --ink-level Obtain the ink level from the printer. This requires read/write access to the raw printer device. -d, --identify Query the printer for make and model information. This requires read/write access to the raw printer device. -o, --align-color Align the color print head (used by Stylus Color 480 and 580 only). CAUTION: Misuse of this option may result in poor print quality and/or damage to the printer. -s, --status Retrieve printer status. -l, --license Display the license/warranty terms of this program. -M, --list-models List the supported printer models. -h, --help Display a list of all command line options. -q, --quiet Suppress the banner. BUGS
USB-connected printers sometimes fail to identify or return ink levels. You may have to repeat the command. This is probably a timing issue in escputil, not a flaw in the printer. Anything requiring bidirectional communication with the printer (identify, ink levels, or head alignment without specifying the printer model) requires read/write access to the printer port (for example /dev/lp0). This may require these operations to be performed as root. In addition, kernel support is required for bidirectional communication. For Linux version 2.2, CONFIG_PRINTER_READBACK should be enabled; this is called CONFIG_PARPORT_1284 on 2.4 and later kernels. If the printer is performing self-test or head cleaning on power up, the identify and ink level commands will time out, although the printer successfully receives the command. The command will need to be reissued when the printer is quiescent. AUTHORS
Robert Krawitz. COPYRIGHT
Copyright (C) 2000 Robert Krawitz (rlk@alum.mit.edu) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. OTHER INFORMATION
The homepage of the Gutenprint project from which this utility was contributed is located at http://gimp-print.sourceforge.net/. SEE ALSO
lp(4), tunelp(8). Version 5.2.9 07 Jul 2012 ESCPUTIL(1)
All times are GMT -4. The time now is 11:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy