Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
i am simply trying to search a file for a specific line, and then duplicate that line immediately after the original - and print the entire file out to another file.
it seems like it should be so simple, but i have tried everything i can think of.
i tried to grep the line using -n to list the line # where it is in the file - and then cut the number into another file - so i have the number 86 in a file. i then used a while loop with x=$((x + 1)) to sed each line into a seperate file - and then when x=86, and matches what's in the file containing 86 - append the line. obviously this is wrong - there must be a very simple way - can anyone help?
here is what i was trying to do...
(the line i want to copy starts with "PS1")
grep '^PS1.*$' profile > words
grep -n '^PS1.*$' profile > line
cut -c1,2 line > num
x=1echo $x > xx
while test xx != num
do
sed -n "$x,1p" profile >> file.txtx=$((x + 1))
echo $x > yycut -c1,2 yy > xx
done
i know the problem is that i can't test a file against another file - but i can't seem to get the 86 from those files into variables.
i'm just starting out - and any help would be greatly appreciated! i know there must be an easier way.

It was obvious that you "did your time" on this one. Actually, I was impressed by your thought processes. When you get the hang of everything - stand back out of the way everybody! :-D

![]() |
Shutdown remotely by a sc...
|
'no os'
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |