How to pipe a file information and bringing it to screen on the same time?
For example I tried out some demos in Swift.
Swift exists as compiler ("swiftc") and as interactive shell ("swift"). And as interactive shell also as interpreter.
If I start it as interactive shell, it looks like the fowllowing example
Code:
$ swift
Welcome to Swift version 5.3 (swift-5.3-RELEASE).
Type :help for assistance.
1> // Create arrays
2> var shoppingList = ["catfish", "water", "tulpis"]
shoppingList: [String] = 3 values {
[0] = "catfish"
[1] = "water"
[2] = "tulpis"
}
3> shoppingList[1] = "bottle of water"
4> print(shoppingList)
["catfish", "bottle of water", "tulpis"]
5> :q
$
The interactive shell shows my input part, the output part and some additional information, which existing only in the interactive shell.
This interactive shell is nice, but some examples are very long. But luckyly, they existing all as swift-files.
This one looks like
Code:
$ cat Example.swift
// Create arrays
var shoppingList = ["catfish", "water", "tulpis"]
shoppingList[1] = "bottle of water"
print(shoppingList)
$
This is the code, which I can compile and run
Code:
$ swiftc Example.swift
$ ./Example
["catfish", "bottle of water", "tulpis"]
$
or interpret it
Code:
$ swift Example.swift
["catfish", "bottle of water", "tulpis"]
$
In both cases, it shown me only the output of the running program. Without my part and without the additional information of the interactive shell.
With
Code:
$ swift < Example.swift
Welcome to Swift version 5.3 (swift-5.3-RELEASE).
Type :help for assistance.
shoppingList: [String] = 3 values {
[0] = "catfish"
[1] = "water"
[2] = "tulpis"
}
["catfish", "bottle of water", "tulpis"]
$
and
Code:
$ cat Example.swift | Example.swift
Welcome to Swift version 5.3 (swift-5.3-RELEASE).
Type :help for assistance.
shoppingList: [String] = 3 values {
[0] = "catfish"
[1] = "water"
[2] = "tulpis"
}
["catfish", "bottle of water", "tulpis"]
$
I can see the additional scripting output information, but I still can't see wahat was input, like when I input it myself like on the top of this posting.
So is it possible, to show the parts of the file and the output and the additional information output all together on the screen in the chronological order?
Greetings
theuserbl