|
|
|
|
Bonjour,
je suis complètement novice avec UNIX et j'aurai besoin d'aide pour réaliser un script sans utiliser ni SED ni AWK. Quelqu'un peut-il m'aider?
Voici l'énoncé :
For the following and any subsequent exercises you ARE NOT permitted to use either SED or AWK.
Script 1
Pre-requisites
Create a file with x amount of lines in it, the content of your choice.
Write a script named 'firstline' that takes two arguments. The first being a line of text, the second being your newly created file. The script should take the first argument and insert it into the very top (the first line) of the file named in your second argument.
Note! The file must retain the original name
Merci.
Configuration: Windows XP Firefox 2.0.0.6
> càd que j'ai plusieurs script à faire, celui-ci est le premier de la
Configuration: Windows XP Firefox 2.0.0.6 |
Contenu du fichier monFichier.txt
|
Merci beacoup Chacual pour ton aide...moi j'étais parti sur une function firstline () {en essayant de faire des couper coller..etc}.
Configuration: Windows XP Firefox 2.0.0.6 |
Salut,
[tmpfs]$ cat plop # le fichier de départ ligne1 ligne2 ligne3 ligne4 [tmpfs]$ cat firstline # le script #! /bin/bash var=$(cat "$2") echo "$1" > "$2" echo "$var" >> "$2" unset var [tmpfs]$ ./firstline "ligne insérée" plop [tmpfs]$ cat plop ligne insérée ligne1 ligne2 ligne3 ligne4 [tmpfs]$;-)) Z'@+...che. JP : Zen, my Nuggets ! ;-) Le savoir n'est bon que s'il est partagé. |