[K12OSN] Most Bash scripting questions? :)

austinsr austinsr at uindy.edu
Thu Dec 11 20:45:15 UTC 2008


If you are looking for the file without the cd /home lines, you could do:
cat .bash_history |grep -v "cd /home" >>/root/logfile.log

The -v flag to grep will exclude the word passed to grep, so you will 
end up with a file without and cd /home lines in it.


Huck wrote:
> was more about stripping out...but either of those will work fine
> I can bastardize another script to rip 'em out...
>
> thanks!
>
> --Huck
>
> austinsr wrote:
>> Huck,
>>
>> This is fairly simple.
>> cat .bash_history |grep home >>/root/logfile.log
>> This will create a file in /root/ called logfile.log that contains 
>> all lines with the word "home" in them.
>>
>> Did you need to remove these entries from .bash_history?  Is this 
>> what you meant by "strip out"?
>>
>> Shawn
>>
>> Huck wrote:
>>> I cat a file...   .bash_history in this case.
>>>
>>> it has...
>>>
>>> ls
>>> cd RadioMadness
>>> ls
>>> cd /home/torkch/profile/Desktop/
>>> ls Research\ Paper/
>>> rm -rf Research\ Paper/
>>> ls
>>> rm Thumbs.db
>>> cd /home/wincst/
>>> ls
>>> ls Physics/
>>> rm -rf Physics/
>>>
>>>
>>> for examply...
>>>
>>>
>>> I want to strip out and KEEP... all lines that say
>>>
>>> cd /home/
>>>
>>> and keep that in a separate file...
>>>
>>> Thanks for the help you Lovely Bash Script Gurus!!!
>>>
>>> _______________________________________________
>>> K12OSN mailing list
>>> K12OSN at redhat.com
>>> https://www.redhat.com/mailman/listinfo/k12osn
>>> For more info see <http://www.k12os.org>
>>
>> _______________________________________________
>> K12OSN mailing list
>> K12OSN at redhat.com
>> https://www.redhat.com/mailman/listinfo/k12osn
>> For more info see <http://www.k12os.org>
>>
>>
>
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>




More information about the K12OSN mailing list