How to create shell script to save then edit and delete data in a file?
Shell scripting write/edit/delete
Here's a script where "ls" creates a file, "sed" edits it by replacing ".zip" with ".tmp", "grep" deletes lines that contain ".tmp". Since it's a bad idea to redirect output to a file being used in the same command, "txt1.tmp" is also used.
and here's the same thing without it creating any files
| Code: |
| #!/bin/bash
ls -1 > "txt.tmp"; # Creates a file sed -e "s/.zip/.tmp/" "txt.tmp" > "txt1.tmp"; # Edits the file grep -v ".tmp" "txt1.tmp" > "txt.tmp"; # Deletes from the file cat "txt.tmp"; rm "txt"*".tmp"; |
and here's the same thing without it creating any files
| Code: |
| #!/bin/bash
ls -1 | sed -e "s/.zip/.tmp/" | grep -v ".tmp" |
thank you
Related topics
