लिनक्स शैल स्ट्रिंग्स में प्रतिशत साइन क्या करता है?

विषयसूची:

लिनक्स शैल स्ट्रिंग्स में प्रतिशत साइन क्या करता है?
लिनक्स शैल स्ट्रिंग्स में प्रतिशत साइन क्या करता है?
Anonim
जब आप लिनक्स शैल का पूरी तरह से उपयोग करने के तरीके सीखने की प्रक्रिया में हैं, तो आप अपने आप को उत्सुकता प्राप्त कर सकते हैं कि सर्वोत्तम परिणाम प्राप्त करने के लिए आप स्ट्रिंग्स में कितना कुशलतापूर्वक उपयोग कर सकते हैं। इस बात को ध्यान में रखते हुए, आज के सुपर यूज़र क्यू एंड ए पोस्ट में एक जिज्ञासु पाठक के सवाल का जवाब है।
जब आप लिनक्स शैल का पूरी तरह से उपयोग करने के तरीके सीखने की प्रक्रिया में हैं, तो आप अपने आप को उत्सुकता प्राप्त कर सकते हैं कि सर्वोत्तम परिणाम प्राप्त करने के लिए आप स्ट्रिंग्स में कितना कुशलतापूर्वक उपयोग कर सकते हैं। इस बात को ध्यान में रखते हुए, आज के सुपर यूज़र क्यू एंड ए पोस्ट में एक जिज्ञासु पाठक के सवाल का जवाब है।

आज का प्रश्न और उत्तर सत्र हमारे पास सुपरयूसर की सौजन्य है - स्टैक एक्सचेंज का एक उपविभाग, क्यू एंड ए वेब साइट्स का एक समुदाय संचालित समूह।

प्रश्न

सुपर यूज़र रीडर निसिम कौफमैन जानना चाहते हैं कि लिनक्स शैल स्ट्रिंग में प्रतिशत चिह्न क्या करता है:

When using the Linux shell, what does the percent sign (%) do? For example:

Image
Image

लिनक्स शैल स्ट्रिंग में प्रतिशत चिह्न क्या करता है?

उत्तर

सुपरयूसर योगदानकर्ता मरेक रोस्ट का जवाब हमारे लिए है:

When the percent sign (%) is used in the pattern ${variable%substring}, it will return content of the variable with the shortest occurrence of substring deleted from the back of the variable.

This function supports wildcard patterns, that is why it accepts an asterisk (star) as a substitute for zero or more characters. It should be mentioned that this is Bash specific. Other Linux shells do not necessarily contain this function.

If you want to learn more about string manipulation in Bash, then I highly suggest reading the following page, Advanced Bash-Scripting Guide: Chapter 10. Manipulating Variables. Among many other handy functions, it explains what a double percent sign (%%) does, for example.

I forgot to mention that when it is used in the pattern $((variable%number)) or $((variable1%$variable2)), the percent sign (%) character will function as a modulo operator.

When the percent sign (%) is used in different contexts, it should be recognized as a regular character only.

स्पष्टीकरण में जोड़ने के लिए कुछ है? टिप्पणियों में विचार व्यक्त करो। अन्य तकनीक-समझदार स्टैक एक्सचेंज उपयोगकर्ताओं से अधिक उत्तरों पढ़ना चाहते हैं? यहां पूर्ण चर्चा धागा देखें।

छवि क्रेडिट: लिनक्स स्क्रीनशॉट (फ़्लिकर)

सिफारिश की: