I want to match the lines of a text file except the last two lines
cat xx
1
2
3
4
5
6
7
8
I want to match 1-6,
I want to match the lines of a text file except the last two lines
cat xx
1
2
3
4
5
6
7
8
I want to match 1-6,
head-n-2 / path/to/file
the answer upstairs is the standard solution, so let me provide another solution.
provides a built-in command mapfile
in bash 4 +
, as explained in the official bash manual:
Read lines from the standard input into the indexed array variable array, or from file descriptor fd if the-u option is supplied.
read a row of data from standard input into an indexed array, or provide the-u option to read row data from a file descriptor
here you can do something interesting with bash's redirection, which is to solve this problem with pure bash built-in commands.
head commands change with execution time, but built-in commands remain stable overall
adopt a reward of 10 yuan, 1045 Access denied for user root @ localhost (using password:NO) recently, when I was at the front end of my self-study, I came into contact with a little bit of database. This happened when I made a new connection on ...
the existing format is as follows: Mon Mar 26 17:43:17 2018 this format is required: 2018-02-21 00:00:00 is there any way to convert it? ...
this looks disgusting! How to get back to that user name @ domain! ...
bash-x ...
I do front-end development, the company develops under linux environment, I install centos6.9 through virtualbox in windows system, use virtualbox to set up a shared folder ( sudo mount-t vboxsf centosShare ~ centosShare ), and can modify fi...
suppose I am in the php copy abc.php shell_exec("git status"); do this I call abc.php on the remote phone but this will not print any code if you type this git status command normally, it will show: On branch master Your branch is u...
Today, I downloaded version 1.12.6 of docker, via yum using Ali CVM, and then downloaded a nginx image using docker. there is no problem at this time, but when you use docker run to create a nginx container, you will disconnect the Xshell remote conne...
linux script command. The shell script itself has log output, but there is no log in the cron expression. What is the reason and how to solve it? shell script command: nohup tcps modules hadoop hadoop-2.6.2 bin hadoop jar tcps modules hadoop jar ca...
if [ "$PS1" ]; then if [ "$BASH" ] && [ "$BASH" != " bin sh" ]; then -sharp The file bash.bashrc already sets the default PS1. -sharp PS1= h: w $ if [ -f etc bash.bashrc ]; then ...
the file opened by running vi etc httpd conf httpd.conf in Linux and xshell is incomplete. Is there any divine guidance on how to solve the problem? Thank you. ...
now there is a binary program shown in the following figure. Generally, I enter. itool daily25.cfg directly into the interface, and then choose the corresponding input according to my own needs. Now I want to call the script with python instead. The in...
-sharp! bin sh filesize=`ls -l nohup.out | awk { print $5 } ` echo "`date +%Y-%m-%d_%H:%M:%S` fileSize: $filesize bit" >> clearNohup.log if [ $filesize -gt 1073741824 ] then echo "`date +%Y-%m-%d_%H:%M:%S` $filesize bigger t...
as follows, ps-ef | grep tproxy | grep-v "grep " command will get tproxy process information, user00 1561 1 0 Apr03 ? 00:01:00 . tproxy --id=1.1.0.6 --port=6001 --conf-file=.. etc proxy.xml --sys-file=.. etc tproxy_sys.xml --env-type=...
< H1 > demand < H1 > needs to execute two commands in one sh file, as follows 1. tail -f log.txt 2. tail -f log2.txt is it feasible because both commands will cause terminal blocking? Or is there any other alternative solution. ...
Shell PHP the shell script is as follows cro_file=$dir_or_file" crontab_php" -sharp if [ -f $cro_file ] then -sharp cat cat $cro_file else echo "$cro_file not found." fi crontab_php conten...
if so, what is the meaning of : in parallel-k echo: A B C > abc_file ? What s the effect? ...
purpose: I want to invoke the shell script in python. The shell script has operations to receive input, and I want to enter these commands in python. description: here is the execution of a .sh shell script, the main function is to have the releva...
failed to build a front-end project using jenkins, which is a problem when viewing jenkins s console log. this shows that the react-router-dom module cannot be found. But I was fine when I was on the local build. Excuse me, what is the problem? ...
as shown in the figure, the ifconfig command can obtain the traffic information of multiple network cards, and now you need to separate the two. Excuse me, what shell command can separate the information of multiple network cards from ifconfig? I trie...
I just looked it up briefly, and I think I got it from some files under the proc directory. I ve seen that the most possible proc pid status file doesn t have shared memory, so I guess it was obtained through some kind of calculation, asking for a...