linux command 2

 

1. ll –tr (will display the file permissions, username and size)
View all files in the current directory
2、fasttext predict-prob textmodel.bin test.txt > predict_result
Append the prediction result of test.txt to predict_result.
3、head predict_result
4、paste -d "\t" predict_result test.txt > result
Paste can be simply understood as merging the contents of two files in columns, which is different from the cat command that directly connects different files in sequence. Paste can quickly arrange the contents of the two files from left to right according to the file order. stand up.

  1. Direct splicing: paste file1 file2 >result (after splicing the contents of file1 and file2 in columns, append them to the result, if not, it will be displayed directly on the terminal)

  2. Use the specified symbol to separate the content of each file when splicing
paste –d ’:‘ file1 file2
5. Use xshell to connect to the server remotely

  1. Transfer files from the server to the local computer
sz
sz filename in your local Downloads directory.

  1. Transfer files from the local computer to the server
Rz
 
6. Batch delete files starting with x under a folder
rm –rf x*
empty folder rm *
delete file A
rm A
 
7. Use the linux split command to split the a.txt file into two files according to 4:1
Eg: file size 4000
Split –b 3000 a.txt
In general, split is used to split, and cat is used to merge.
Two files are generated, approximately 4:1 in size.
8. find command
find –name s*
Find files starting with s.
9. Rename A to B with mv
mv A B
10. Look for the keyword "molar stick" in source_data/6994_cps.data
grep "Molar Stick" 6994_cps.data
grep -v "molar sticks" 6994_cps.data Find lines that do not contain molar sticks
 
11. Disorganize all the files in the folder item_data and append them to 6994_cps.data in the previous directory.
[admin@A01-R03-I186-88 item_data]$
cat * | sort -R > ../6994_cps.data
12. View the total number of files in item_data
 
13. Save the log file generated by .sh to the corresponding log file.
View the log log:
tail -f A.log
 
14, linux command to see how many files are in a folder 2
1) See how many files and folders there are: ls | wc -w
2) See how many files there are: ls | wc -c
 
15. Find the text line for 7029 and hamster in the 6994_cpssrc.data file
Method Two:
 
 
16. Disorganize the content of the file file and put it in file1: sort -R file > file1
        Put the first n lines in file1 into file2, head -n file1 > file2
        Delete the first n lines of file1. Put it in file3, sed -i 1, nd file1 > file3 
 
 
17、
Delete the same in f2 as in f1
 
 
18. Replace the content 6994 in the f1 file that meets the conditions with 6998
E.g:
 
This is what I found out and needs to be changed. How to use the command to change 13967 to 13964 in a folder that meets the conditions of Totoro at one time.
 
Answer: grep "13967" f1 |grep "Chinchilla">f2 (Find out the text with 13967 and Chinchilla from f1 and store it in f2)
grep -vf f2 f1>f3 (delete the same part in f1 and f2 and save it to sub f3)
vim f2 
Input: %s /13967/13964/g (open vim and enter the following command at the bottom to replace 13967 in f2 with 13964)
cat f2 f3 >f4 (merge f2 and f3 into f4)
then f4 is the result
 
15. View the process: pos
 
16. View the JAVA process:
[root @ ipdetl-d684256f lirui] # ps -f | grep java
 
[root@ipdetl-d684256f lirui]# hadoop fs -ls /user/lirui/sentiment/lcs/12218/model_data_diff
 
17, linux command, vim calls a file, the copy command is yyp
 
18、 cat 6994_cps.data | cut -f1| sort | uniq -c|sort -rnk1
Look at the first few columns of text.
 
19. sort | uniq to remove duplicates
 
20. Only view the content of lines 20 to 30 in the test.txt file (100 lines) (enterprise interview)
[root@Gin scripts]# awk '{if(NR>=20 && NR<=30) print $1}' test.txt
   awk -F ":"  '{ print $1 }'  /etc/passwd
  Indicates to print the content of /etc/passwd
 
21、cat 6994_cps.data | cut -f1| sort | uniq -c|sort -rnk1
Open the 6994_cps.data file and extract the first field
 
22. Usage of linux cut
 
Its syntax format is:
cut  [-bn] [file] 或 cut [-c] [file]  或  cut [-df] [file]
The cut command cuts bytes, characters, and fields from each line of a file, and writes these bytes, characters, and fields to standard output.
If you do not specify the file parameter, cut will read standard input, you must specify -b -c -f.
-b byte -c character -d custom delimiter -f Used with -d to specify which area to display.
 
[rocrocket@rocrocket programming]$ cat /etc/passwd|head -n 5
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
[rocrocket@rocrocket programming]$ cat /etc/passwd|head -n 5|cut -d : -f 1
root
bin
daemon
adm
lp
 
23、linux sort 
Sort the content of the text file, sort can sort the content of the text file in line units.
 
24. Back up all files and directories in a directory under linux
cp -rf source directory backup directory
cp is the copy command
-r Recursive processing, files and subdirectories in the specified directory are processed together
-f force copy, whether target exists or not
Copy the same file A in the same directory
Method 1: cp -f A
Method 2: cp A A.bak
 
25. How to copy a line in the vim panel of the linux text operation interface
1) Move the cursor to the line to be copied
2) Press yy
3) Move the cursor to the position to be copied
4) Press p
 
Press u to return, that is to delete the copied one.
 
 
26. View unique tags in text
 
awk '{print $1}' txt | sort | uniq > tt
 
27. Remove the data of <fell> in item
mv 1429 tt
ls * 1429
\rm *1429
mv tt 1429
 
 
28. Real tab key in vim
:set list 
The tab key is displayed as ^I and the end is displayed as $.
 
29、Python pandas 

 

Pandas provides us with a rich interface for reading files, which is extremely convenient for data processing

 
30. 2/8 participle command
 
31. awk gets the first column in the text.
 
awk is a text line processing command
-F'\t' split by \t
'{print $1}' prints the first column $2 means the second column
 
32. De-duplication
cat a.txt |sort|uniq
 
33. Check the usage of gpu
nvidia-smi
 
34. View the current process
ps -f
 
34 View packages installed by pip
pip list
 
35. Look at our process
top
 
36. Take out the different parts of the two files and store them in AAA
diff file1.txt file2.txt >AAA
 
37. Run a code in the background: nohup sh run_camera.sh &
 
38. Look at the size of the generated file:
du -sh *
 
39. Kill background processes
1. Find the background process [admin@A01-R03-I186-88 codelirui]$ ps -ef |grep run_camera.sh
2. Kill him kill -9 8058
3. Check to see if you have killed ps -ef |grep run_camera.sh
 
 
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325184183&siteId=291194637