06-22-2004
Thanks
I just ran a small awk script to accomplish what I needed to do, but I wanted to find out if there was a much better way to do it for next time.
Driver, thanks for the program. I was looking for someway to access the file from the end ( essentially what your last for loop does), but just from the shell ( instead of writing a program).
I like Jim's solution, but yes wc -l takes some time. I dont know sed yet, but I am learning it.
Thanks everybody.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
For lists in sed, to say what to replace, is this correct:
I am hoping that this would recognise that either a "." is present, or that the substitution happens at the end of the line.
For files with extensions , my script works perfectly.
My problem is, files without extentions, i.e. . ... (1 Reply)
Discussion started by: busillis
1 Replies
2. UNIX for Dummies Questions & Answers
How to copy entire file content into another file being in last line mode of vi ?
---------- Post updated at 10:07 AM ---------- Previous update was at 09:56 AM ----------
Got it :
:1,30w file.txt (1 Reply)
Discussion started by: presul
1 Replies
3. Shell Programming and Scripting
Hi,
I am having a file which is fix length and comma seperated. And I want to replace values for one column.
I am reading file line by line in variable $LINE and then replacing the string.
Problem is after changing value and writing new file temp5.txt, formating of original file is getting... (8 Replies)
Discussion started by: Mruda
8 Replies
4. Shell Programming and Scripting
Hi ,
I need your kind help for my below requirement
I need to copy and entire txt file to a certain position to the target file .
Source file has 3 lines and it has to be copied to the target file in position from line 10 to 12.
Thanks for your support (1 Reply)
Discussion started by: Pratik4891
1 Replies
5. Shell Programming and Scripting
Hi
I have a data file 'File2' consisting of 105670 lines. I want to copy and paste 17928 lines from 'File1' to 'File2' but I want to place it in between lines 21 and 17950 of 'File2'. How do I do it in awk?
For example-
File A has 5 lines
X
Y
1 2 3
4 5 6
7 8 9
and File B has
A
b... (1 Reply)
Discussion started by: ananyob
1 Replies
6. Shell Programming and Scripting
Hi
I have a data file 'File2' consisting of 105670 lines. I want to copy and paste 17928 lines from 'File1' to 'File2' but I want to place it in between lines 21 and 17950 of 'File2'. How do I do it in awk?
For example-
File A has 5 lines
X
Y
1 2 3
4 5 6
7 8 9
and File B has
A
b... (1 Reply)
Discussion started by: ananyob
1 Replies
7. Shell Programming and Scripting
I have a text file that has data like:
Data "12345#22"
Fred
ID 12345
Age 45
Wilma
Dino
Data "123#22"
Tarzan
ID 123
Age 33
Jane
I need to figure out a way of adding 1,000,000 to the specific lines (always same format) in the file, so it becomes:
Data "1012345#22"
Fred
ID... (16 Replies)
Discussion started by: say170
16 Replies
8. Shell Programming and Scripting
Hi,
How do we write the contents of multiple files created in awk body to a new file in awk (END block) ? when I used "getline", it is consuming more time. Do we have any other way other than getline? (1 Reply)
Discussion started by: Cool
1 Replies
9. Shell Programming and Scripting
so i have several files that look somewhat like this:
{
"afafa": "afaf",
"afafaa" : ""
}
<newline>
<newline>
i want to grab everything in the file except the empty new lines at the end. note, there may be newlines within the content itself.
(
"afafa": "afaf",... (3 Replies)
Discussion started by: SkySmart
3 Replies
10. Shell Programming and Scripting
Greetings.
I've got a csv file with data along these lines:
Spumoni's Pizza Place, Placemats n Things, Just Lamps
Counterfeit Dollars by Vinnie, Just Shades, Dollar StoreI want to replace the entire comma-delimited field if it matches something ending in "Place" or beginning with "Dollar",... (2 Replies)
Discussion started by: palmfrond
2 Replies
SLEEP(1) BSD General Commands Manual SLEEP(1)
NAME
sleep -- suspend execution for an interval of time
SYNOPSIS
sleep seconds
DESCRIPTION
The sleep command suspends execution for a minimum of seconds.
If the sleep command receives a signal, it takes the standard action.
IMPLEMENTATION NOTES
The SIGALRM signal is not handled specially by this implementation.
The sleep command will accept and honor a non-integer number of specified seconds (with a '.' character as a decimal point). This is a non-
portable extension, and its use will nearly guarantee that a shell script will not execute properly on another system.
EXIT STATUS
The sleep utility exits 0 on success, and >0 if an error occurs.
EXAMPLES
To schedule the execution of a command for x number seconds later (with csh(1)):
(sleep 1800; sh command_file >& errors)&
This incantation would wait a half hour before running the script command_file. (See the at(1) utility.)
To reiteratively run a command (with the csh(1)):
while (1)
if (! -r zzz.rawdata) then
sleep 300
else
foreach i (`ls *.rawdata`)
sleep 70
awk -f collapse_data $i >> results
end
break
endif
end
The scenario for a script such as this might be: a program currently running is taking longer than expected to process a series of files, and
it would be nice to have another program start processing the files created by the first program as soon as it is finished (when zzz.rawdata
is created). The script checks every five minutes for the file zzz.rawdata, when the file is found, then another portion processing is done
courteously by sleeping for 70 seconds in between each awk job.
SEE ALSO
nanosleep(2), sleep(3)
STANDARDS
The sleep command is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible.
HISTORY
A sleep command appeared in Version 4 AT&T UNIX.
BSD
April 18, 1994 BSD