Linux shell scripts replace backslash __linux

Source: Internet
Author: User

1 script in Windows, the path is backslash \, in Linux, the path is slash/, you need to replace the backslash with a slash, using the SED command, as follows
Sed-i "s:\\\:\/:g"/home/pp/install.sql replaces \ sed-i "S:04risk\::ig" in/home/pp/install.sql file *.sql Replace the 04risk\ in all SQL files with null and case-insensitive, and the parameter I indicates case-insensitive.
2 Displays the results of the Linux command execution, using the echo $ (Linux command) or the Keng number, Keng is the character on the left side of keyboard 1, not single quotes. For example, display the current path, echo $ (PWD), or echo ' pwd ' 3) to get the current directory path, basename $ (PWD) 4) for the loop to read the directory and its subdirectories #!         /bin/bash function Read_dir () {for file in ' ls ' does if [-D $/' $file]//Note there must be a space between here, otherwise it will be an error         then//replace all SQL files with backslashes sed-i "s:\\\:\/:g"/"$file"/"*.sql Read_dir $"/"$file else echo $ "/" $file fi Done}

Read_dir $





     

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.