[Question]
  [
A kitten is much like a cat. Some of the main differences are cuteness, lack of intelligence, and size. Similarly, the `cat` command is different from the `kitten` command. Fortunately, there is only one difference in this case. In the kitten command, all uppercase letters are replaced with lowercase letters.
---
# Objective
To implement a program that behaves similarly to `cat`. All characters `[A-Z]` are outputted lowercase.
---
# Input
A list of files as command line arguments. If no files are listed, then read from standard input. The input may contain unprintable characters and characters outside the ASCII range.
---
# Output
If input is a bunch of files, concatenate the contents and output all characters as lowercase. If reading from STDIN, output the contents of STDIN with all uppercase letters as lowercase.
Note: Only make the characters `[A-Z]` lowercase. It is unacceptable if any other characters are made lowercase.
---
## Examples
```
$ echo "HelLo" > file.txt
$ kitten file.txt
hello
$ echo "Good Bye" | kitten
good bye
$ echo "Ä" | kitten
Ä
```
As usual with [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), least bytes wins.
## Leaderboards
---
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
```
# Language Name, N bytes
```
where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance:
```
# Ruby, <s>104</s> <s>101</s> 96 bytes
```
If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header:
```
# Perl, 43 + 2 (-p flag) = 45 bytes
```
You can also make the language name a link which will then show up in the leaderboard snippet:
```
# [><>](http://esolangs.org/wiki/Fish), 121 bytes
```
```
var QUESTION_ID=59029,OVERRIDE_USER=32700;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"http://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```
```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```
  
[Answer]
# Bash, 19 bytes
```
cat "$@"|tr A-Z a-z
```
The best way to make kittens is to use actual cats.
### Example run
```
$ ./kitten kitten
cat "$@"|tr a-z a-z
```
[Answer]
# Perl, 6 bytes
5 bytes code + 1 byte command line
```
$_=lc
```
Example usage:
```
echo ABCdef | perl -p kitten.pl
abcdef
```
Confirmation of correct Unicode behaviour:
```
echo "HelloÉ" | perl -p kitten.pl
helloÉ
```
[Answer]
# Perl, 11 bytes
10 bytes code + 1 byte command line
```
y/A-Z/a-z/
```
Example usage:
```
perl -p entry.pl input1.txt input2.txt
echo "ABCdef" | perl -p entry.pl
```
[Answer]
# Python 3, 77 bytes
```
from fileinput import*
print(end=b''.join(input(mode='rb')).lower().decode())
```
[Answer]
# Ruby, 13 bytes
The byte count includes 1 byte for the `p` flag. Run it like so: `ruby -p kitten.rb`.
```
$_.downcase!
```
Takes input from stdin or file arguments, just like grown up cat.
[Answer]
# PowerShell, 112 Bytes
```
function l([string]$a){97..122|%{[char]$b=$_;$a=$a-split$b-join$b};$a}if($args){$args|%{l(gc $_)}}else{l $input}
```
Horrendously unreadable. Here's a slightly expanded version below:
```
function l([string]$a){
  97..122|%{
    [char]$b=$_
    $a=$a-split$b-join$b
  }
  $a
}
if($args){
  $args|%{
    l(gc $_)
  }
}
else{
  l $input
}
```
Defines an internal function `l` which iterates over a loop from 97 to 112 (i.e., ASCII `a` to ASCII `z`). Splits the input string over that character (yay case-insensitive default), the rejoins it with the "correct" lower case. Do note that yes, this means "Test" would briefly become "T st" as it's iterating through the `e`, for example. Doesn't affect output.
The second half is the tricky bit to figure out if we have pipeline input (equivalent to stdin for PowerShell) or command-line input. The special variable `$args` is only present if command-line input is present, so we loop over each one, `gc` (for `Get-Content`) and schlep that up to `l`. Otherwise, we just schlep our `$input` up to `l`. Note that we could swap our if/else statements (i.e., `if($input)`), but since "input" is one character longer than "args" this way is shorter.
[Answer]
# R, 97 bytes
```
cat(chartr("A-Z","a-z",sapply(if(length(a<-commandArgs(T))){a}else{"stdin"},readLines)),sep="\n")
```
Usage:
```
$ echo "HeLlo" > file.txt
$ Rscript kitten.R file.txt
hello
$ echo "Good Bye" | Rscript kitten.R
good bye
$ echo "bLABLa" > file2.txt
$ Rscript kitten.R file.txt file2.txt
hello
blabla
$ echo Ä | Rscript kitten.R
Ä
```
[Answer]
# [CoffeeScript](http://coffeescript.org), 292 bytes
```
f=require 'fs';d='';p=process;v=p.argv;s=p.stdin;l=((d)=>console.log d.replace /([A-Z])/g,(a,l)=>l.toLowerCase());if v.length>2 then(v.forEach (v,i)=>if i>1 then(f.exists v, (e) =>if e then(f.readFile v,'utf-8',(r,d)=>l d) else l v))else(s.resume();(s.on 'data',(c)=>d+=c);s.on 'end',()=>l d)
```
Usage:
```
$ echo "HelLo" > file.txt
$ coffee kitten.coffee file.txt
hello
$ echo "Good Bye" | coffee kitten.coffee
good bye
$ echo "Ä" | kitten
Ä
$ coffee kitten.coffee file.txt SoMeTeXt
sometext
hello
```
My first participation on codegolf so please don't be rude :).
For sure this code can be golfed more and coffee/javascript isn't the best choice to do that, but it does what's expected.
When it reads arguments it also takes care about file existency (if file does not exists, the string is kittened.)
Any help or advice to improve this code is welcome !
[Answer]
# Julia, 123 bytes
```
f(s)=for l=readlines(s) print(replace(l,r"[A-Z]",lowercase))end
A=ARGS
length(A)>0?for i=A open(f,i)end:open(f,readline())
```
Ungolfed:
```
function file_to_lower(s::Stream)
    # Loop over the lines of the input stream
    for l in readlines(r)
        # Print the lowercased line
        print(replace(l, r"[A-Z]", lowercase))
    end
end
if length(ARGS) > 0
    # Loop over the files specified from the command line
    for i in ARGS
        # Open the file, apply the function, then close it
        open(file_to_lower, i)
    end
else
    # Get the input file from STDIN
    open(file_to_lower, readline())
end
```
[Answer]
# Python 2, 53 bytes
```
from fileinput import*
print''.join(input()).lower(),
```
[Answer]
# C, ~~106~~ 108 bytes
*Edit: Fixed a mistake that creeped in when squeezing bytes. Stdin wasn't working, now it is.*
I'm pretty sure I could squeeze some bytes away, but here's an easy-to-grasp, not at all language abusive, submission:
```
main(n,s,f,c)void**s;{for(f=n-1?open(*++s,0,0):0;read(f,&c,1);putchar(64<c&c<91?c+32:c));n-->2&&main(n,s);}
```
And a somewhat more neatly formatted version for reading:
```
main(n,s,f,c)
void**s;
{
    for(f=n-1?open(*++s,0,0):0; read(f,&c,1); putchar(64<c&c<91?c+32:c));
    n-->2&&main(n,s);
}
```
[Answer]
# CJam, 18 bytes
```
ea_:gs{q}?'_,_eler
```
The list of files must be supplied in form of URLs, which is the only format CJam understands.
### Example runs
```
$ cjam kitten <<< "AaÁáÄä"
aaÁáÄä
$ cjam kitten file:///home/dennis/kitten file:///home/dennis/kitten
ea_:gs{q}?'_,_elerea_:gs{q}?'_,_eler
```
### How it works
```
ea                  Push the array of command-line arguments.
  _                 Push a copy.
   :g               Retrieve the contents of all files with those URLS.
     s              Flatten the resulting array of strings.
      {q}           Push a block that reads all input from STDIN.
         ?          Select the string of the array of args is non-empty.
                    Otherwise, execute the code block.
          '_,       Push the string of all ASCII characters before _.
             _el    Push a copy and convert it to lowercase.
                er  Perform transliteration.
```
[Answer]
# Python 2, ~~100~~ ~~102~~ 97 bytes
*Functionality corrected (and 4 bytes added) by matsjoyce. Fortunately, I saved two bytes by switching to Python 2.*
```
from sys import*;print''.join(f.read().lower()for f in(map(open,argv[1:])if argv[1:]else[stdin]))
```
Takes arguments from the command line, or from STDIN if no arguments found.
This abuses the default arguments of some functions. By default, `open` uses read-only text mode, which is exactly what we want. `read`, if called with no arguments, will return all text in the stream.
Ungolfed:
```
import sys
if len(sys.argv) > 1:              # If we have command-line arguments:
    source = []                    # Initialize an empty list
    for path in sys.argv[1:]:      # Iterate through every filename we have
        kitfile = open(path, 'rt') # Open the file in read-only text mode
        source.append(kitfile)     # Add it to the list
else:                              # Otherwise, if the args are empty:
    source = [sys.stdin]           # Set our source to STDIN wrapped in a list
kittened = []                      # Initialize an empty list
for kitfile in source:             # Iterate through every file (or just STDIN)
    text = kitfile.read()          # Read everything from the stream
    kitten_text = text.lower()     # Make it lowercase
    kittened.append(kitten_text)   # Add it to the list
final = ''.join(kittened)          # Join everything together
print final                        # Print the result
```
[Answer]
# Python 3, ~~124~~ 123 bytes
---
```
from sys import*
for f in list(map(open,argv[1:]))or[stdin]:print(f.read().translate({i:i+32for i in range(65,91)}),end="")
```
[Python eats kittens!](https://www.google.co.uk/search?q=python+eats+kitten)
```
$ python kitten.py file.txt
hello
$ echo "Good Bye" | python kitten.py 
good bye
$ echo "Ä" | python kitten.py 
Ä
```
[Answer]
# Mathematica, 66 bytes
```
kit=StringReplace[#,x:RegularExpression["[A-Z]"]:>ToLowerCase[x]]&
```
Called as 
```
kit@"HelLo"
```
Mathematica already has a [`ToLowerCase`](http://reference.wolfram.com/language/ref/ToLowerCase.html) function, but it converts special (Unicode and mathematical) characters as well. So I had to kittenize it. This function will take any input.
[Answer]
# C#, ~~230~~ 226 bytes
```
namespace System{using Linq;class P{static void Main(string[]a){Console.Write(string.Concat((a.Length>0?string.Concat(a.Select(f=>IO.File.ReadAllText(f))):Console.In.ReadToEnd()).Select(c=>c>'@'&&c<'['?char.ToLower(c):c)));}}}
```
Ungolfed: 
```
namespace System
{
    using Linq;
    class P
    {
        static void Main(string[] a)
        {
            Console.Write(                                                  // Print...
                string.Concat(                                                  // ...all chars combined to a string...
                    (a.Length > 0 ?                                             // ...commandline arguments?...
                        string.Concat(a.Select(f => IO.File.ReadAllText(f))) :  // ...then all files as single string...
                        Console.In.ReadToEnd()                                  // ...else STDIN input
                    ).Select(c => c > '@' && c < '[' ? char.ToLower(c) : c)     // ...Lowercase only A..Z
                )
            );  
        }
    }
}
```
[Answer]
## Haskell, 133
```
import System.Environment
main=getArgs>>=mapM_(>>=putStr.map l).f
f[]=[getContents]
f n=map readFile n
l x=[x..]!!sum[32|x>'@',x<'[']
```
The cat-style args processing is derived from [this tutorial](https://wiki.haskell.org/Tutorials/Programming_Haskell/Argument_handling), then rearranged to shave characters.
Explaining `l`, the function to lowercase one character:
* `sum[32|condition]` is a shorter form of `if condition then 32 else 0`.
* `[x..]!!count` is `iterate succ x !! count` is `toEnum $ fromEnum x + count` and shorter than importing and using `Data.Char.toLower` with a condition to restrict it to ASCII.
* `'@'` and `'['` are the characters immediately preceding `A` and following `Z`, so that I can use `<` instead of `<=`.
Thanks to Anders Kaseorg for contributing the `sum[...|...]` and `[x..]!!` tricks.
[Answer]
# C#, 342 bytes
* takes file list from passed arguments.
* read every char in every file than only converts to lower case if and only if the character in the A..Z range than send it to STDOUT.
* If there is no file list than reads STDIN, reads every char, converts to lower case if and only if the character in the A..Z range than send it to STDOUT.
```
namespace System{
using IO;
using Linq;
class P{
static void Main(string[]a){
Action<char>e=C=>{var c=char.ToLower(C);Console.Out.Write(c>='a'&&c<='z'?c:C);};
if(a.Length>0)a.ToList().ForEach(f=>File.ReadAllText(f).ToCharArray().ToList().ForEach(e));
else 
while(true) Console.In.ReadLine().ToCharArray().ToList().ForEach(e);
}
}
}
```
# C#, 319 bytes
single-liner, same as above:
```
namespace System{using IO;using Linq;class P{static void Main(string[]a){Action<char>e=C=>{var c=char.ToLower(C);Console.Out.Write(c>='a'&&c<='z'?c:C);};if(a.Length>0)a.ToList().ForEach(f=>File.ReadAllText(f).ToCharArray().ToList().ForEach(e));else while(true)Console.In.ReadLine().ToCharArray().ToList().ForEach(e);}}}
```
[Answer]
# S.I.L.O.S 179 characters
```
loadLine :
a = 256
x = get a
lbla
X = x
B = x
C = 91
B - 64
if B c
printChar x
GOTO x
lblc
C - x
if C D
printChar x
GOTO x
lblD
x + 32
printChar x
lblx
a + 1
x = get a
if x a
lblb
```
Feel free to [try this code online!](http://silos.tryitonline.net/#code=bG9hZExpbmUgOgphID0gMjU2CnggPSBnZXQgYQpsYmxhClggPSB4CkIgPSB4CkMgPSA5MQpCIC0gNjQKaWYgQiBjCnByaW50Q2hhciB4CkdPVE8geApsYmxjCkMgLSB4CmlmIEMgRApwcmludENoYXIgeApHT1RPIHgKbGJsRAp4ICsgMzIKcHJpbnRDaGFyIHgKbGJseAphICsgMQp4ID0gZ2V0IGEKaWYgeCBhCmxibGI&input=&args=VEVTVElORyBURVNUSU5HIEZvbyBCYXIKMTIz)
---
Essentially it translates to this in pusedocode.
```
String input = input();
for(char c in input)
if(c is uppercase) print c + 32/*lowercase c*/else print c
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 4 bytes
```
AuA‡
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fsdTxUcPC//89UnN88gE "05AB1E – Try It Online") Beats all other answers.
```
AuA‡  # full program
   ‡  # replace all characters of...
A     # "abcdefghijklmnopqrstuvwxyz"...
 u    # in uppercase...
   ‡  # with corresponding character in...
  A   # "abcdefghijklmnopqrstuvwxyz"...
   ‡  # in...
      # implicit input
      # implicit output
```
[Answer]
# [Julia 1.x](http://julialang.org/), 65 bytes
```
!s=print.(c+32('@'<c<'[') for c=read(s,String))
.!ARGS>[]||!stdin
```
[Try it online! (stdin)](https://tio.run/##yyrNyUw0rPj/X7HYtqAoM69ETyNZ29hIQ91B3SbZRj1aXVMhLb9IIdm2KDUxRaNYJ7gEqChdU5NLT9ExyD3YLjq2pkaxuCQlM@///8Sk5JTUtHQPTy9vH18//4DAoOCQ0LDwiMiow50gaGhkAgA "Julia 1.0 – Try It Online")
[Try it online! (files)](https://tio.run/##yyrNyUw0rPj/X7HYtqAoM69ETyNZ29hIQ91B3SbZRj1aXVMhLb9IIdm2KDUxRaNYJ7gEqChdU5NLT9ExyD3YLjq2pkaxuCQlM@@/sq2Co5Ozi6vb4c7DDWC48vCCxKTklNQ0BVvl/yn5Cnn5JQpgSxRyU//rJeenpOqVZOYjWAA "Julia 1.0 – Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 24 [bitsv1](https://github.com/Vyxal/Vyncode/blob/main/README.md), 3 bytes
```
kAnĿ
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=1#WyI9IiwiIiwia0FuxL8iLCIiLCLDhGJDIl0=)
The power of context variable overloads and range coding! Simply transliterate the uppercase alphabet to the lowercase alphabet.
[Answer]
# sed, 14 bytes
```
s/[A-Z]/\L\0/g
```
Run with `env -i sed -f kitten.sed`.
[Answer]
# Java, 198 bytes
```
b->B->{B="";for(java.io.File c:b)B+=new java.util.Scanner(c).useDelimiter("\\Z").next();for(int c=0;c++<B.length;)if(B.charAt(c)>64&B.charAt(c)<91)B=B.replace(B.charAt(c),B.charAt(c)|32);return B;};
```
You are forced to use the above lambda with files, so there's no need to take input from STDIN! Also, it's a `Function<File[], UnaryOperator<String>>`. It's used like `foo.apply(anArrayOfFiles).apply(anything)`.
As something that makes more sense to those who are new to Java, it takes 223 bytes:
```
String A(java.io.File[]b){String B="";for(java.io.File c:b)B+=new java.util.Scanner(c).useDelimiter("\\Z").next();for(int c=0;c++<B.length;)if(B.charAt(c)>64&B.charAt(c)<91)B=B.replace(B.charAt(c),B.charAt(c)|32);return B;}
```
As something that compiles, it takes up 232 bytes:
```
class a{String A(java.io.File[]b){String B="";for(java.io.File c:b)B+=new java.util.Scanner(c).useDelimiter("\\Z").next();for(int c=0;c++<B.length;)if(B.charAt(c)>64&B.charAt(c)<91)B=B.replace(B.charAt(c),B.charAt(c)|32);return B;}}
```
[Answer]
# [Go](//golang.org), 89 bytes
```
package main
import(."fmt"
."strings")
func main(){s:=""
for{Scan(&s)
print(ToLower(s))}}
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 5 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
;dBíC
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=O2RC7UM&input=IkhlbExvCkdvb2QgQnllCsQiIA)
# [Japt](https://github.com/ETHproductions/japt) v2.0a0, 5 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
r\A_v
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&code=clxBX3Y&input=IkhlbExvCkdvb2QgQnllCsQiIA)
]