I got 40 scripting files (.sh) in a directory.
Each file has a line called
I need to replace X with the name of the file, so if file name is abc1.sh and abc2.sh then in both these files the line would read as
javac abc1.java //# or javac abc2.java as for other file.
Can i write a script which will traverse all these files one by one and replace the string "X" with the name of the file?
I got 40 scripting files (.sh) in a directory, like abc1.sh, abc2.sh, abc3.sh.. and so on till abc40.sh. I need to create as many java files corresponding to each, ie, abc1.java, abc2.java .... abc40.java. I dont care about contents in them.
Using sed to edit the file and output is redirected to a new file
The sed utility is a stream editor that reads one or more
text files, makes editing changes according to a script of
editing commands, and writes the results to standard output.
Substitute the replacement string for
instances of the regular expression in the
pattern space. Any character other than
backslash or newline can be used instead of a
slash to delimit the RE and the replacement.