Sponsored Content
Top Forums Shell Programming and Scripting how to view last line of multiple files Post 302319210 by methyl on Sunday 24th of May 2009 04:23:06 PM
Old 05-24-2009
Code:
#!/bin/ksh
for filename in "file 1" "file 2" "file 3"
do
         # If there is anything in the file, show which file and the last line
         if [ -s "${filename}" ]
         then
                 ls -lad "${filename}"
                 # tail hyphen one shows the last line
                 tail -1 "${filename}"
                 echo ""
         fi
done


Last edited by methyl; 05-24-2009 at 05:26 PM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Multiple view of Apsedic to ASCII.

dd conv=ascii if=100.PCN of=foo On paging the 'foo' file i get conversion of the selected file. How can I get multiple 100.PCN's into 1 'foo' file. Usually all my work related files have an extension of .PCN or 001. Upon selecting if=*.* No ouput file is generated. (2 Replies)
Discussion started by: buRst
2 Replies

2. Shell Programming and Scripting

How to Eliminate first line of multiple files

hi gurus ,, I have multiple files with same file pattern..in a particular directory for ex: file20061101.trf file20061102.trf file20061103.trf Each of the file has a header as column names.. My questions is how can i eliminate the first row of each of these... (11 Replies)
Discussion started by: sish78
11 Replies

3. Shell Programming and Scripting

Appending same tring to multiple files in one line?

I have a string that I need to append to 3 files. Say, $ echo "Hello" I want to append this “Hello” to three files, file1, file2 and file3.The files are all in different directories and the file names have no common pattern.Can I do it in one line? If yes, how? :confused: (2 Replies)
Discussion started by: zombiezparadize
2 Replies

4. Shell Programming and Scripting

bash: cat multiple files together except first line?

Hopefully the title summarized what I need help with. I have multiple files that I would like to concatenate in bash. ie: cat file1 file2 file3 > bigfile except I do not want to include the first line from each file (). Any help? Thanks. (6 Replies)
Discussion started by: sanimfj
6 Replies

5. UNIX for Dummies Questions & Answers

Finding nth line across multiple files

I have several files (around 50) that have the similar format. I need to extract the 5th line from every file and output that into a text file. So far, I have been able to figure out how to do it for a single file: $ awk 'NR==5' text1.txt > results.txt OR $ sed -n '5p' text1.txt > results.txt... (6 Replies)
Discussion started by: oriqin
6 Replies

6. Shell Programming and Scripting

How to View multiple Cron jobs

Hi, I ran two crontab commands using: crontab program1 crontab program2 However when I type crontab -l only the second cron job shows up, how do I see all cron jobs running and how do I edit all at the same time Thanks in Advance S:D (10 Replies)
Discussion started by: walforum
10 Replies

7. Shell Programming and Scripting

insert filename into each line of multiple files

I need to insert <filename + comma> into each line of multiple files. Any idea how to script that? Regards, Manu (5 Replies)
Discussion started by: linux.yahoo
5 Replies

8. UNIX for Dummies Questions & Answers

Want to change common line from multiple files

Hi everyone, I've a requirement to modify an existing line which is common to multiple files. I need to replace that existing line with a new line. I've almost 900 ksh files to edit in the similar fashion in the same directory. Example: Existing Line: . $HOME/.eff.env (notice the "." at the... (3 Replies)
Discussion started by: kaleem.adil
3 Replies

9. UNIX for Dummies Questions & Answers

Insert a line into multiple files

HI All, I want to know if it is possible to print the same message but into 2 different files in the same command? Something like . .. ... echo "Text" >> file1 && file2 this is because i creating a script which i use a log but i don't want to duplicate lines of command just to... (5 Replies)
Discussion started by: lordseiya
5 Replies

10. Shell Programming and Scripting

Perl command line option '-n','-p' and multiple files: can it know a file name of a printed line?

I am looking for help in processing of those options: '-n' or '-p' I understand what they do and how to use them. But, I would like to use them with more than one file (and without any shell-loop; loading the 'perl' once.) I did try it and -n works on 2 files. Question is: - is it possible to... (6 Replies)
Discussion started by: alex_5161
6 Replies
dtinfoaction(file formats)												dtinfoaction(file formats)

NAME
dtinfoaction -- CDE information management actions SYNOPSIS
DtLoadInfoLib filename Open filename DtShowInfoAtLoc DtPrintInfoAtLoc DESCRIPTION
The CDE Information Management Services support the following information management actions: DtLoadInfoLib filename Load the information library specified by filename, which can be either a relative or absolute file path. If filename is not specified, dtinfo displays the default information library(s). Open filename Load the information library specified by filename. Remaps to DtLoadInfoLib filename. DtShowInfoAtLoc filename section Display the section or topic specified by section contained within the infolib specified by filename. filename can be either a relative or absolute file path. section specifies the information library section in generalized locator format. dtinfo is started if it is not already running. This corresponds to invoking dtinfo with the -sect option from the command line. DtPrintInfoAtLoc Print one or more infolib sections from the desktop. This action is invoked whenever a section or sections is dragged from the book list window in dtinfo and dropped on the printer icon on the front panel. These actions can be invoked from an application using the DtActionInvoke(3) function or invoked from a command line using the dtaction(1) utility. SEE ALSO
dtinfo(1), DtActionInvoke(3), DtInfo_LoadInfoLib(4), DtInfo_PrintInfoAtLoc(4), DtInfo_ShowInfoAtLoc 4 dtinfoaction(file formats)
All times are GMT -4. The time now is 04:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy