hi all i need to write a simple bash script that lists all PHP files in a directory and writes the first 5 lines of each PHP-file to new file called : PHP_header
i know only the basic in linux command line
#!/bin/bash
grep –r stringsearch
find /opt/-name ‘log_*’
du –s foldername
head -10 filename
mkdir filername.php
please explain me how can i complet this
This should do:
To add some explanation:
for f in *.phpThe loop iterates over all
.phpfiles in the current working directory.head -5This command prints the first five lines of a file to
STDOUT.done > PHP_headerThe redirection (
>) at the end of the loop redirectsSTDOUTfor everything printed inside the loop to the filePHP_header.