generation of control file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting generation of control file
# 1  
Old 02-15-2012
generation of control file

Hi,
I wanted to create a control file with data in it.
Also wanted to append more points like
1)Row count, then print the first field
2)first line of the file
3)last line of the file
I started with this:-
Code:
ls -ltr *.*| awk ' { print $9 "|" $7 $6 $8 "|" $5 } '
sed -n '1p';
sed -n '$p';

Moderator's Comments:
Mod Comment How to use code tags

Last edited by Franklin52; 02-15-2012 at 04:21 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 02-15-2012
Doing it one shot (file is red once)
Code:
$ cat f1
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
41 42 43 44 45
51 52 53 54 55
61 62 63 64 65
71 72 73 74 75
81 82 83 84 85
91 92 93 94 95
$ awk 'NR==1{f=$1;l=$0}{c=$0}END{print "Line number:" NR,"First field:"f RS "First line:"l RS "Last Line:"c}' f1
Line number:9 First field:11
First line:11 12 13 14 15
Last Line:91 92 93 94 95
$

This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 02-15-2012
Code:
sed -n '$s/.*/Line Number-> /p;$=' file1 |sed 'N;s/\n//';sed -n -e '1s/\([^ ]*\).*/First Field-> \1/p' file1;sed -ne '1s/.*/FIRSTLINE-> &/p' -e '$s/.*/LASTLINE-> &/p' file1
Line Number-> 9
First Field-> 11
FIRSTLINE-> 11 12 13 14 15
LASTLINE-> 91 92 93 94 95

regards
ygemici
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Xls file generation

Hi Team, Is it possible to generate the xls OR xlsx file factility in Unix and xls file should be more than one sheet. (2 Replies)
Discussion started by: bmk123
2 Replies

2. UNIX for Dummies Questions & Answers

Core File Generation

Hi I am using Linux and I am using Java as well as C++ services running on it. The ulimit -c is set to around 400Mb. Whenever any of the service fails they produce a core file.(Actual size of core could be greater than 400Mb). Whenever my Java service fails I get a core file of size 400Mb... (3 Replies)
Discussion started by: Raj999
3 Replies

3. Shell Programming and Scripting

Help with file generation

Dear all Hope you are doing good. I've requirement where in I need to generate a file containing set of SQLs as per the inputs. My script flow is like reading few parameters using read command to read input to script and process the inputs. However at one of the input, my script has to... (3 Replies)
Discussion started by: tenderfoot
3 Replies

4. UNIX for Dummies Questions & Answers

Log file generation from crontab

Hi All, Like to enquire whether is it possible for me to append another log file(log2.lst) using my below crontab? I will need to have 2 log files generated; one to collect the daily appended output and another log file that contains only the daily output. Original Code: 00 01 * * *... (2 Replies)
Discussion started by: snowfrost88
2 Replies

5. Shell Programming and Scripting

Dynamic file generation using shell

I have to generate the file dynamically from the source file based on the below control file. control_file.txt 1,3,5,-1,8,-1,4 The control file contain the position of column which i required from the source file, Example 1 column ,3 column ,5 column ,blank column(-1 indicates blank... (2 Replies)
Discussion started by: rspwilliam
2 Replies

6. UNIX for Dummies Questions & Answers

XML File Generation - Template Help

Hi, I have hit a bit of a brick wall.:confused: need the following code edited: echo "<?xml version=\"1.0\"?><dailyBalance_ROWSET>" > ${DataDir}/${extract_script}${ApplicationDate}.${Suffix} RunSQL ${extract_script} ${ActionFlag} echo "</dailyBalance_ROWSET>" >>... (2 Replies)
Discussion started by: Xergxes7
2 Replies

7. Shell Programming and Scripting

File Report Generation

hi all i need to generate a report file that contains the following details of files present in a directory. 1. File name 2.Complete path for each files and directory 3.File size 4.Days older example i have a directory testing that contains sub-directories and some files. i need to make a... (5 Replies)
Discussion started by: yashwantkumar
5 Replies

8. Shell Programming and Scripting

file generation and mail notification

I'm very new to unix. I need help in writing a shell script that will automatically take output file from a particular folder from a server and if the file is generated send email notifications to certain group of ppl and if it is not generated send a mail wid error msg.. can any1 help me on... (4 Replies)
Discussion started by: anzie.sharma
4 Replies

9. UNIX for Dummies Questions & Answers

mail notification on file generation

I'm very new to unix. I need help in writing a shell script that will automatically take output file from a particular folder from a server and if the file is generated send email notifications to certain group of ppl and if it is not generated send a mail wid error msg.. can any1 help me on... (2 Replies)
Discussion started by: anzie.sharma
2 Replies
Login or Register to Ask a Question