Script to search every file in a directory and print last few lines
Hi everyone,
I need to write a script to search a directory, output the name of a file to an ouput file and print the last few lines of the files to the output file such that I would have something like this:
Any ideas?
Moderator's Comments:
Please use CODE tags as required by forum rules!
In this case, it would have helped tremendously as it would show if you're talking of one single output file or three files...
Last edited by RudiC; 11-09-2016 at 05:58 PM..
Reason: Added CODE tags assuming one single output file.
hello
have a file1
H87I
Y788O
T347U
J23U
and
file2 J23U U887Y I99U T556U
file3 I99O J99T F557J
file4 N99I T666U R55Y
file5 H87I T347U
file6 H77U R556Y E44T
file7 Y788O K98U H8I
May be using script we can use file1 to search for all the files
and have the output
H87I file5... (3 Replies)
hi,
I have a file say x.txt containing
xxx
123
bla
bla
...
you
xxx
dfk
dbf
...
me
xxx
...
...
keeps on..
i need to search for pattern in the line starting xxx in the file. If pattern matched, I need to fetch all the lines till i find next xxx. (17 Replies)
Hi,
I am new to ksh scripting and I have a problem.
I have a file in which I have to search for a particular pattern say 'a' then from that line I need to search for another pattern say 'b' in the previous lines and thne print the file from pattern 'b' till the end of file.
For eg:
... (2 Replies)
I have a command which prints #lines after and before the search string in the huge file
nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r;print;c=a}b{r=$0}' b=0 a=10 s="STRING1" FILE
The file is 5 gig big.
It works great and prints 10 lines after the lines which contains search string in... (8 Replies)
Good Evening Folks -
I have a need to search a specific directory and ALL sub-directories for the following string:
Data Load UpdatedIf this string is found, I need to print content from the line directory above it between symbols, as well as the file name where it is found.
Here is a... (1 Reply)
Hi All,
I hope somebody would be able to help me.
I would need to search a string coming from a file, example file.txt:
dog
cat
goat
horse
fish
For every string, I would need to know if there are any files inside a directory(recursively) that contains the string regardless of case.... (9 Replies)
I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with:
wc -l *|sort
15263 Image.txt
16401 reference.txt
40459 richtexteditor.txt
How can I also print the number of unique lines in each file?
15263 1401 Image.txt
16401... (15 Replies)
Discussion started by: spacegoose
15 Replies
LEARN ABOUT DEBIAN
medit
MEDIT(1) General Commands Manual MEDIT(1)NAME
medit - text editor
SYNOPSIS
medit [OPTION]... [FILES]
DESCRIPTION
medit is a text editor.
OPTIONS -n, --new-app
run new instance of medit. By default medit opens FILES (or creates a new document if none are given) in an existing instance of
application
-s, --use-session[=yes|no]
load and save session. By default medit does it when -n is not used. If this option is not given on command line then medit uses
the corresponding preferences setting.
--pid PID
use existing instance with process id PID.
--app-name NAME
use instance name NAME. If an instance with this name is already running, then it will send files given on the command line to that
instance and exit.
-e, --encoding ENCODING
use provided character encoding to open the file
-l, --line LINE
open file and position cursor on line LINE. Alternatively line number may be specified with filename, e.g. medit foo.txt:12
-r, --reload
automatically reload opened file if it was modified on disk by another program.
-w, --new-window
open file in a new window.
-t, --new-tab
open file in a new tab.
--log-file FILE
write debug output into FILE. This option is only useful on Windows.
--log-window
show debug output in a log window. This option is only useful on Windows.
--debug DOMAINS
enable debug output for DOMAINS (if medit was compiled with --enable-debug option).
--geometry WIDTHxHEIGHT
--geometry WIDTHxHEIGHT+X+Y
default window size and position.
-h, --help
show summary of options.
-v, --version
show program version.
FILES list of files to open. Filenames may include line numbers after colon, e.g. /tmp/file.txt:200. Trailing colon is ignored.
ENVIRONMENT VARIABLES
MEDIT_PID
if set, it is used as --pid argument. When medit spawns a process (e.g. a DVI viewer) it sets MEDIT_PID to its own process id, so
the child process may in turn simply use 'medit filename' to open a file (e.g. for inverse DVI search).
CONTACT
http://mooedit.sourceforge.net/contact.html
AUTHOR
Written and maintained by Yevgen Muntyan <emuntyan@users.sourceforge.net>
September 2010 MEDIT(1)