Linux uname command Example | Linux get OS Info
Linux chown Command In Hindi : chown Command Examples
wc Command In Linux | Linux count characters in line or file
JavaScript Object keys, values, entries : Object methods in JS
PHP stdClass In Hindi | stdClass In PHP
JavaScript Web Worker Example | Web Workers In JavaScript In Hindi
JavaScript Event Loop In Hindi | Understand Event Loop In JS In Hindi
Variables In Snowflake In Hindi | Snowflake Variables In Hindi
If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
Hello everyone, I Hope आप सभी लोग अच्छे हैं। आपने कभी न कभी Linux में cat
command का use file content को print करने के लिए तो किया ही होगा। अगर नहीं तो भी कोई बात नहीं। इस blog में हम cat command के purpose , need और कुछ useful practical examples को देखेंगे।
●●●
Linux में cat की full form concatenate है। cat command एक बहुत ही useful command है , इसका use करके आप files create कर सकते हैं , file content को print कर सकते हैं, files को concatenate कर सकते हैं और file output redirection कर सकते हैं।
cat [options] [filename]
cat
command को ">"
operator के साथ use करके आप किसी file को create भी कर सकते हैं।
For example -
~/learning$ cat > file.txt
जब आप ऊपर दी गयी command run करने के बाद आप जो भी content file में write करना चाहते हैं वो write कर सकते हैं। फिर CTRL+d
press करने पर content उस file में save हो जयगा।
~/learning$ cat >file.txt this is the text i want to write in the file here I can write anything that I want ctrl+d
अब ls command का use करके आप created file को list करा सकते हैं।
~/learning$ ls file1.txt
Linux में ls
command का use directories या directory contents को list करने के लिए किया जाता है। By default यह सभी visible files और directory को list करता है।
learn more about ls command ...
Ok , तो current directory में file.txt file create हो चुकी है। अब इस file के अंदर के content को print कराते हैं।
~/learning$ cat file.txt this is the text i want to write in the file here I can write anything that I want
cat file.txt
का use करके file content को print cat command का default nature है , हालाँकि cat command में और भी कई options हैं जिसे आप cat --help run
करके देख सकते हैं।
~/learning$ cat --help Usage: cat [OPTION]... [FILE]... Concatenate FILE(s) to standard output. With no FILE, or when FILE is -, read standard input. -A, --show-all equivalent to -vET -b, --number-nonblank number nonempty output lines, overrides -n -e equivalent to -vE -E, --show-ends display $ at end of each line -n, --number number all output lines -s, --squeeze-blank suppress repeated empty output lines -t equivalent to -vT -T, --show-tabs display TAB characters as ^I -u (ignored) -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB --help display this help and exit --version output version information and exit and some other info
file content को line number के साथ show करने के लिए आप cat के साथ --number
या -n
का use कर सकते हैं।
~/learning$ cat --number file.txt 1 this is the text 2 i want to write in the file 3 here I can write anything that I want
file में use किये गए tab spaces को determine करने के लिए आप --show-tabs
या -T
option का use कर सकते हैं। तो जहाँ पर भी अपने tab use किया होगा वहां पर ‘^I’
add हो जयगा। हालाँकि content add करते time मैंने कोई tab नहीं लिया था। इसलिए example में output normal है।
~/learning$ cat -T file.txt this is the text i want to write in the file here I can write anything that I want
output में हर line के end में $ sign show करने के लिए -E
या --show-ends
option का use किया जाता है।
~/learning$ cat -E file.txt this is the text$ i want to write in the file$ here I can write anything that I want$
किसी एक file के content को किसी दूसरी file में content redirect / copy करने के लिए filename के बाद >
operator का use किया जाता है। For example -
~/learning$ cat file.txt > new_file.txt ~/learning$ cat new_file.txt this is the text i want to write in the file here I can write anything that I want
cat command के साथ आप एक साथ एक से ज्यादा files के name pass करके सभी file के content को एक साथ भी show कर सकते हैं।
Example के लिए , new_file.txt file में कुछ नया content write करके दोनों files के content को print कराते हैं।
~/learning$ cat > new_file.txt content in new_file fot testing ctrl+d ~/learning$ cat new_file.txt file.txt content in new_file fot testingthis is the text i want to write in the file here I can write anything that I want
I Hope, Linux में आपको cat command के बारे में अच्छे से समझ आ गया होगा। :)
Loading ...
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook