当前位置:网站首页>Shell input validation alphanumeric only
Shell input validation alphanumeric only
2022-06-26 06:57:00 【My talented girlfriend】
#!/bin/bash # Allow text to execute as a script , Interpreter
valiaAlphaNum(){
validchars="$(echo $1 | set -e 's/[^[:alnum:]]//g')"
# Be sure to pay attention to shell Assignment statement for = There is no space on the left and right sides of the sign
# set Put variables in it like a channel ,-e Multiple matches [:alnum:] Represents letters and numbers Sometimes it will lead to : Disappear , Write normally
if [ "$validchars"="$1" ]; then
return 0
else
return 1
fi
}
/bin/echo -n "Enter input:"
read input
# Read the input characters
if ! valiaAlphaNum "$input" ; then
# Notice the ! Number and valiaAlphaNum There's a space between
echo "you input must consist of only letters and numbers.">&2
exit 1
else
echo "input is valid."
fi
exit 0
边栏推荐
- Closure problem C Lua
- Market scale forecast and investment risk forecast report of China's securities operating institutions 2022-2027
- Web technology sharing | webrtc recording video stream
- Kotlin compose state recovery remembersaveable and remember
- [image fusion] MRI-CT image fusion based on gradient energy, local energy and PCA fusion rules with matlab code
- Load balancer does not have available server for client: userService问题解决
- [image enhancement] image defogging based on artificial multiple exposure fusion amef with matlab code
- When vs code uses prettier to format JS, there is a space between the name of the function definition and the parentheses, and ESLIt does not allow this space
- 我在腾讯做测试的这几年...
- 遇到女司机业余开滴滴,日入500!
猜你喜欢
![[micro service series] protocol buffer dynamic analysis](/img/86/357d55c77cc67d6413af2de59bf395.png)
[micro service series] protocol buffer dynamic analysis

Closure problem C Lua

SecureCRT运行SparkShell 删除键出现乱码的解法

闭包问题C# Lua

直播预告丨消防安全讲师培训“云课堂”即将开讲!

MySQL基础用法01

Guide to "avoid dismissal during probation period"

遇到女司机业余开滴滴,日入500!

MySQL 数据库的小白安装与登录

Open source demo| you draw and I guess -- make your life more interesting
随机推荐
Judgment of SQL null value
MySQL基础用法01
Closure problem C Lua
SQL Basics
【图像增强】基于人工多重曝光融合AMEF实现图像去雾附matlab代码
STM32F1与STM32CubeIDE编程实例-热敏传感器驱动
直播预告丨消防安全讲师培训“云课堂”即将开讲!
浅析一道经典题
Phantom star VR equipment product details II: dark battlefield
How to transfer database data to check box
Kotlin Compose 状态恢复 rememberSaveable 与 remember
Research Report on sales scale forecast and investment opportunities of China's jewelry industry 2022-2027
Mysql delete in 不走索引的
SQL中空值的判断
Show statement usage supplement
[micro service series] protocol buffer dynamic analysis
[digital signal processing] basic sequence (basic sequence lists | unit pulse sequence | unit pulse function | discrete unit pulse function | difference between unit pulse function and discrete unit p
Solution of garbled code in sparkshell deletion key of SecureCRT
MATLAB线性规划模型学习笔记
Rust中的过程宏