An unsolved problem-general Linux technology-Linux programming and kernel information. The following is a detailed description. Author: Deng
The cause of the problem is as follows: in the first item of/etc/fstab of ubuntu, the UUID = ××××× format is used. I was wondering if I could write a script to replace this line with the classic device name, such as/dev/sda1.
In this way, you can see the correspondence between the uuid and the device name. Since the correspondence has come out, all the conditions are ready. Then the problem came out. When I used awk and sed tools in the past, the replaced content was represented by a regular expression, while the replaced content was often fixed. The problem now is that the replaced content corresponds to a certain ing relationship. Although I have this table on hand, It is irregular for the program, it can only be matched by reading it, which is a tricky place for me.
# Enter the uuid and the corresponding device name will be returned.
# The next step is to write the implementation part.
Awk 'in in {FS = "[\ t =] + "}
# FS = "[\ t =] +"} refers to the use of spaces, TAB keys, and equal signs as separators and the addition of "+" to ensure that separators can overlap.
# Output all rows that do not match UUID without modification
# Replace the UUID-matched rows. This is also the focus, but I cannot implement it.
$1 ~ /UUID /{
"$2 = 'replace _ uuid $2 '"
# This is where the problem occurs. I want to call the function from here to replace it, but it seems that the call does not work. Of course, I tried some other methods to solve this problem. Maybe using "cut and paste" is a solution, but I always believe that there is always a solution, but I have not been enlightened yet.
Print $2, $3, $4, $5, $6, $7, $8, $9
} '/Etc/fstab
# Conclusion: although this problem is a bit tricky, it is a type of problem for me. This is why I don't know how to implement the alternative content when it becomes unstable. I think it is because I call shell, especially custom functions, in awk, I am not familiar with it, maybe I did not understand it.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service