我有一個看起來像如何找出殼列式,並獲得差異
emp_id(int),name(string),age(int)
1,hasa,34
2,dafa,45
3,fasa,12
8f,123Rag,12
8,fafl,12
要求的示例文件:列數據類型指定爲字符串和整數。 Emp_id應該是一個不是字符串的整數。這些條件對於名稱和年齡列是相同的。
我的輸出應該像#
Actual column Emp_id type is INT but string was found at the position 4, value is 8f
Actual column name type is STRING but numbers were found at the position 4, value is 123Rag
繼續..
這裏是我的代碼 shell腳本
read input
if [ $input -eq $input 2>/dev/null ]
then
echo "$input is an integer"
else
echo "$input is not an integer"
fi
在Python中,我與Isinstance嘗試(OBJ ,類型),但它沒有達到目的。 可以在這方面指導我,任何shell/python/perl腳本的幫助將不勝感激!
您的代碼與您的要求無關。至少表現出誠實的嘗試。 – karakfa
[BASH:測試字符串是否作爲一個整數有效嗎?]可能的重複(http://stackoverflow.com/questions/2210349/bash-test-whether-string-is-valid-as-an-integer) – tripleee
什麼是將數字放入字符串字段的問題? –