Sponsored Content
Top Forums Shell Programming and Scripting Get "n" number of lines from the specified file and store the output to the new file Post 302678675 by 244an on Sunday 29th of July 2012 10:40:31 AM
Old 07-29-2012
I think the second error is because there are nothing in $FILENAME because of the first error with basename. This is how to get basename another way: ${1##*/} (if you want it from $1).

I don't understand PATH and FILE in your script, they don't get any values?

I also think you must have a loop in the last part:
Quote:
Originally Posted by zsycho
...
Code:
...
elif [ -r ${SAVEPATH}${FILENAME}.$(date +%Y%m%d).$COUNT ]; then
  COUNT=`expr $COUNT + 1`
  tail -n $2 $1 > ${PATH}${FILENAME}.$(date +%Y%m%d).$COUNT
fi

should be:
Code:
...
else
  while [ -r ${SAVEPATH}${FILENAME}.$(date +%Y%m%d).$COUNT ]; do
    COUNT=`expr $COUNT + 1`
  done
  tail -n $2 $1 > ${PATH}${FILENAME}.$(date +%Y%m%d).$COUNT
fi


Last edited by 244an; 07-29-2012 at 11:48 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to store the output of "time dd if= of=" in a variable

Hi All, I need to store the real seconds of the following command in a variable. How could it be done? time $(dd if=/dev/zero of=/dev/sda1 bs=512 count=2048;sync) Thanks, Amio (12 Replies)
Discussion started by: amio
12 Replies

2. Shell Programming and Scripting

"sed" to check file size & echo " " to destination file

Hi, I've modified the syslogd source to include a thread that will keep track of a timer(or a timer thread). My intention is to check the file size of /var/log/messages in every one minute & if the size is more than 128KB, do a echo " " > /var/log/messages, so that the file size will be set... (7 Replies)
Discussion started by: jockey007
7 Replies

3. Shell Programming and Scripting

store the output of "find" command in a variable?

I intend to find the path/full location of a file(filename given by user thru "read filenme") using "find" or any other command and then store it's output in a variable for some other processing. But struggling to put all things together (i.e finding the fully qualified location of that file and... (4 Replies)
Discussion started by: punitpa
4 Replies

4. Shell Programming and Scripting

ksh script that echo " please insert your name " and store the output to a login.log file.

Hello All Nice to meet you all here in this forum, it's my 1rst time here i'm asking about a little issue that i face i added a ksh script that echo " please insert your name " and store the output to a login.log file. the script is working fine with normal telnet but Xstart is not working... (8 Replies)
Discussion started by: islam.said
8 Replies

5. Shell Programming and Scripting

Store date-of-birth as "1#7#0#2#" in file

Hello, My input files are having header/body/footer. The first three digits finds whether the data is header/body/footer. For example, 010AAAAA 20100507 234KB BBBBBBBBBB_20100506.DAT 020CCCCC DDDDDDDDD 373983983 19750426 456.90 ... (1 Reply)
Discussion started by: nvkuriseti
1 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. UNIX for Dummies Questions & Answers

Deleting "user input line number" from a file using sed

Hi I want to delete a line from a txt file for which the line number is user input. Say when user selects 19, the 19th line would be deleted from the file. Can anyone please provide me with a sed one liner for the same... I tried sed -i. The interaction would be like this Enter the line to... (1 Reply)
Discussion started by: sudeep.id
1 Replies

8. Shell Programming and Scripting

Deleting "user input line number" from a file using sed

Hi I want to delete a line from a txt file for which the line number is user input. Say when user selects 19, the 19th line would be deleted from the file. Can anyone please provide me with a sed one liner for the same... I tried sed -i. The interaction would be like this Enter the line... (4 Replies)
Discussion started by: sudeep.id
4 Replies

9. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

10. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
sendiso(1)							  Linux IEEE 1394							sendiso(1)

NAME
sendiso - send IEEE 1394 isochronous packets from dump file SYNOPSIS
sendiso [ options ] FILE DESCRIPTION
sendiso takes the dump file FILE as generated by dumpiso(1), extracts the packets and sends them as they were received (in the same order, with the same channel numbers) as fast as possible - timing of the original dump is not preserved. This program does not allocate any isochronous resources but just starts sending. It should not be used in live environments where it might interfere with properly set up isochronous transmissions, it is a debug and performance benchmarking tool. OPTIONS
-l, --loop=COUNT Send dump file COUNT times. Defaults to 1. -i, --infinite Send dump file in an endless loop. -s, --speed=SPEED Send packets at speed SPEED, which can be given as 100, 200 and 400 (in Mbit/s) or abbreviated as 1, 2 and 4. Defaults to 100. -p, --port=PORT Choose port PORT for sending. A port is a 1394 card or chip and represents one connected bus, therefore this is only relevant when you have multiple of these. Defaults to 0. -h, --help Show help text and exit. BUGS
None known. SEE ALSO
dumpiso(1), isodump(5) AUTHOR
Andreas Bombe <aeb@debian.org> libraw1394 2.1.0 sendiso(1)
All times are GMT -4. The time now is 04:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy