Hey all, I have been tasked with specifically making vim commands work in a shell script for an assessment and I cant for the life of me find stuff to help figure out how to do it.
I have searched around online and only ever found things that gave answers like "just try this instead its easier", though if I used something else I wouldn't get marked on it. I have also looked through the books we were given and didn't really find anything on this specifically either.
Here's some more context. Question : "Create and test a Linux script called 'setup.sh' that contains all the previous commands and save it in your Assessment directory."
The tasks before that were, in this order:
1 - Create a directory in the home directory called 'Assessment'
2 - Create 2 directories called 'Source' and 'Destination' in the 'Assessment' directory
3 - Create 2 files named 'File1.txt' and 'File2.txt' inside 'Assessment/Source'
4 - Write your Name and DOB in 'File1.txt' using a Linux editor VIM
5 - Copy only the txt files from 'Source' to 'Destination'
6 - Apply the following permissions to the 'Assessment' directory (User: Read Write Execute, Group: Read, Other: Read)
7 - Pipe a directory listing using long listing format of 'Assessment' directory contents and save as 'listing.txt' in 'Assessment'
Now I know how to do those previous 7 tasks but I am struggling at the VIM part within a shell script as it does not like "vi file1.txt". "command not found". The closest things I found online were things saying that adding "-c" would allow it to do commands for VIM.. But then followed up by how to reverse the lines in the txt file.
From that I tried " vi File1.txt -c 'i' echo "name dob" -c ':wq' " but that didn't work for me. (I am very new to Linux, aka never used outside of this assessment)
Let me be clear though; I am not looking for an outright answer to this, just for some help/point me in the right direction so I can learn how to do it.
Any help is highly appreciated.
I have searched around online and only ever found things that gave answers like "just try this instead its easier", though if I used something else I wouldn't get marked on it. I have also looked through the books we were given and didn't really find anything on this specifically either.
Here's some more context. Question : "Create and test a Linux script called 'setup.sh' that contains all the previous commands and save it in your Assessment directory."
The tasks before that were, in this order:
1 - Create a directory in the home directory called 'Assessment'
2 - Create 2 directories called 'Source' and 'Destination' in the 'Assessment' directory
3 - Create 2 files named 'File1.txt' and 'File2.txt' inside 'Assessment/Source'
4 - Write your Name and DOB in 'File1.txt' using a Linux editor VIM
5 - Copy only the txt files from 'Source' to 'Destination'
6 - Apply the following permissions to the 'Assessment' directory (User: Read Write Execute, Group: Read, Other: Read)
7 - Pipe a directory listing using long listing format of 'Assessment' directory contents and save as 'listing.txt' in 'Assessment'
Now I know how to do those previous 7 tasks but I am struggling at the VIM part within a shell script as it does not like "vi file1.txt". "command not found". The closest things I found online were things saying that adding "-c" would allow it to do commands for VIM.. But then followed up by how to reverse the lines in the txt file.
From that I tried " vi File1.txt -c 'i' echo "name dob" -c ':wq' " but that didn't work for me. (I am very new to Linux, aka never used outside of this assessment)
Let me be clear though; I am not looking for an outright answer to this, just for some help/point me in the right direction so I can learn how to do it.
Any help is highly appreciated.