General :: System Bash Shell Copy Previous Lines (not History) With Keyboard?
Jun 14, 2011
Is it possible to use the keyboard in order to select some text in the terminal windows that is not in the currently edited line? (for example, in order to copy part of previous command output).
Possible Duplicate: Can history files be unified in bash? I have bash running in an ssh session, call this session A. I leave the office, go home, ssh to the same box, call this session B. From session B, I'd like to be able to look at the history of session A.
How can I get/filter history entries in a specific range?I have a large history file and frequently usehistory | grep somecommandNow, my memory is pretty bad and I also want to see what else I did around the time I entered the command.For now I do this:get match, say 4992 somecommand, then I do history | grep 49[0-9][0-9]this is usually good enough, but I would much rather do it more precisely, that is see commands from 4972 to 5012, that is 20 commands before and 20 after. I am wondering if there is an easier way? I suspect, a custom script is in order, but perhaps someone else has done something similar before.
I know how to redirect the output of a terminal to a file. For example, if I want to list all the files in ~/Documents and output to a file called test.txt, I would do this: ls ~/Documents > test.txt The question is, can I copy the output to test.txt AFTER I have carried out the command? This would mean that I wouldn't have to know in advance whether I want to copy the output to file. I want to do something like this: ls ~/Documents Then this: <bash command for copying standard output to test.txt>
I want to copy a file (home/remote_computer_user/Desktop/test1.txt) from my remote office computer (a permanent URL + open port) to my home computer (home/home_computer_user/Downloads/).
How can I do this with shell commands in Linux?
My current thoughts:
ssh <user>@<computer1address> -p <port> - gives me a shell on the remote computer (I think I should use scp, but I dont how exactly how in my case)
I named a number of files with spaces in them, and I want to replace the space with "_". However, every time I write a command in the shell with the file name (eg "Spring 2011"), the shell doesn't recognize the file or directory. What can I do about this? Is there any way to use the unicode character for a space?
I'd like to know some good resources, links, e-books to learn basic Linux system administration scripting. I know how to write very basic BASH shell scripts so I'm still at beginner level. There are so many docs out there that I'd like to narrow down people's opinion's on the best easy to understand resources that are available. Eventually I'd like to learn basic PERL as well.
For reasons I won't get into, I need to copy directories so long as the average system load is low. Can someone help me write a BASH script that will copy the contents of a directory, but check to make sure the average system load is below X before copying each file, and if not, wait Y seconds and try again?
How is shell history specific to each tty? I can't see anything in the history files that would indicate which tty a command was performed on, however if I restart and log in on several ttys, the command order and history is preserved on each. How is this accomplished? This goes for zsh and bash equally.Now for some zsh specific questions.I had a saved webpae, which resulted in a file called doku.php.htm, and a directory called doku.php_files - I could only get zsh to expand the directory. It didnt seem to give me the option to cycle nor did it only complete as much as it could with ambiguity, i.e. to doku.php , so what is this behaviour and where can I read about it?
Secondly I would like to know why zsh interactive shells do not expand the PS1 prompt completely. Whenever I open an xterm or such, the prompt is not the normal PS1 prompt. I read through the manuals and config files, and could see nowhere that staed a different prompt should be used depending on the shell type. Why does this happen, and how can I modify this behavior?Regarding modules, if I install the compat-wifi modules which I assume replace the existing ones, how would I uninstall them? Would I just reinstall the normal kernel modules over them?
In my organization, we have a centralized home directory for all users which gets mounted from all the machine where user logs in.Since any XYZ user can login to any of hundreds test machines and run 'sudo su - myusername', hence taking control of my home dir.How do I track who took control of my home dir and deleted its contents.
i have RHEL4. i m facing problem that all the previous command history is deleted when i restart the server or relogin the server. it is happening with all the users not with any one user.
I am new to Minix. I'm so impressed by the speed of the system. It looks elegant, I like it. However, I have a question about the shell. In Linux, while using a shell, up and down arrow keys can be used to navigate through previously executed commands. On Minix with the sh shell, I can only get numbers printed out on the screen. I remember I chose a US-std keyboard when installing. Is there any way to use the arrow keys to navigate through previous commands on Minix?
I would like to keep track of not only what bash commands I used and when, but also where they were issued from, i.e. what was the current working directory when I issued "foobar" on a particular day and time. Can we ask bash history to keep track of working directories too? I have tried to get an idea of this reading the enormous "man bash", but I don't seem to have an answer yet either way.
I have a file that contains 100 ligns, i need to write a script that read 70 lignes and redirect those 70 ligns to another files and these 70ligns have to be erased in the first file
when i write this command head -70 somefile.txt>test.txt or
sed -n 70p somefile.txt>test.txt
i have these 70 lines in the text.txt files but these 70 lines have to be deleted inthe first file somefile.txt
i have a text file generated automatically from a script , but the result in the script is not ordered in a readable way, so i need your help to fix it using a shell command the text file contain data in this way :
i want to arrange the data in this text file in a way that each line will concatenate the 2 lines after it , so that will be 1 line , i want all the lines to be treated in this way ,
I am trying to fix a perl script, and I really suck at perl. But I think this problem will be easy for people who know it.
The problem is, I have an old setup script someone wrote many years ago. It fails if the standard shell is dash and not bash. The only way I've gotten it to work is to point /bin/sh to bash. I looked thru the script and it uses "system" many places, and I think that's the problem.
I searched for it and found this link:url
My plan is to include this function:
Code: sub system_bash { my @args = ( "bash", "-c", shift ); system(@args); } Then I could simply change all calls to system into system_bash and it should work?
The parameter to the system calls is usually some variable. What if the parameter is a list already? Do I need to test for it somehow, and if it's a list, prepend "bash" and "-c" to the list? How do I do that?
In the script there are lots of places like this:
my $error = system($cmd); if ($error) { die/warn "some error message"; }
Shouldn't there be a return in the system_bash function?
I'm trying to write a bash script to find all lines containing two different strings in many files. I don't have access to egrep so I want to use sed for this purpose.
The files will look like this: FileX ------ Info:18 Data:76 Contact:me@home.com Start:1500
I want to generate a new file from these files with only the rows containing Data and Start. Something like this: for y in `ls /file*.db`; do sed '/Data|Start/p' $y > newfile done
I have a file called test. It has the following contents.Code:there youI want the output to be.Code:replaced youI am trying to use the sed command to replace every occurance of "hey newline there" with "replaced". I tried the following naive apporach.Code:sed 's/heythere/replace/' testThis gives a result containing the same data as the test file.
A function by name abc is called in many files. I want to copy all the lines with the function call to an output file.A simple grep on function name doesn't help me as the function call is spanning across multiple lines as follows:
abc(parameter1, parameter2, parameter3);
So I want to copy all the three lines (till semicolon) to the output file.The problem is because there are more than 200 calls for the same function and I cannot do it manually
I am using squid proxy server for sharing Internet in my internal network. I would like to know that how can I check the browsing history by individual users web surfing history by their IP addresses?
I have installed fail2ban and it is working great. It is monitoring the auth.log and it's own log. Now here is my question... Every week, my log files rotate, which is just fine for the most part. But this also rotates the fail2ban log and removes any chance of catching a repeated IP from Sunday to Monday. Is it possible to copy a portion of the previous log to the new log?Here is my scenario of what I would like to accomplish, but I am a novice here so please be specific..
logrotate does its job as expected... then a script writes a portion of the previous log to the new log then appends a word/number after that portion (we call this log.1)...next time the log rotates (creating log.2), I want to take the portion of log.1 after the word/number and append it to log.2 along with another word/numberThis will always ensure there is at least 1 week backlog in the logs for fail2ban to track. I don't want to just change the frequency of the log-roll because it doesn't solve the issue of tracking across the log roll