FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Shell scripting write/edit/delete

 


akoni176
How to create shell script to save then edit and delete data in a file?
jmraker
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.

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"
bymenchek
thank you
Related topics

Edit / Delete
Complete Tutorial LINKS for every language
150 frh$ for menubar Please CLOSE
Best filemanager?
Spam Assassin level.

Language
What computer languages you know?
Best Blogging software
my world rocks
Help with PhpBB

Shoutbox?
Free php Editor
HTML editing Software
the best photo gallery around?
Script to automatically restart Apache (for server 1)
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.