Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

shell - CPANEL Terminal add 2 x lines of text at start of a document

I am a little new to all this but have been playing around.

I have a CPANEL Server and need to add some text to a specific file. Its 2 x lines of text and needs to be added to the start of the file.

I have managed to do this with the sed -i method but two things i cant do ;

  1. Add it to the start and not replacing something
  2. I actually need to scan the main directory, sub directories and sub sub directories for many files all the same name. Then i need to add it to each of these files. Each folder (there is about 100) has the same file i need editing in, and some sub sub folders also have it.

So to clarify, if anyone can help ;

  1. I need to add 2 x lines of text to the start of a file 'thisfile.txt'
  2. I need to add a space under this inserted text, before the original text continues
  3. There is multiple files in many places in many directories. I need to target them all in the same way.
  4. There is Sub directories and sub sub directories
  5. I am using a Cpanel server with terminal

Thanks in advance. Looking forward to help and playing around with this.

Apologies for quite a few tags. Not 100% sure who to be aiming at. Im new here.

question from:https://stackoverflow.com/questions/65869568/cpanel-terminal-add-2-x-lines-of-text-at-start-of-a-document

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...