4 Eylül 2016 Pazar

for loop in linux terminal

   I have a folder which has 3 files:

..$ ls
file1 file2 file3

Let's make a for loop:

..$ for x in `ls`
> do
> echo $x
> done;

The output:

file1
file2
file3


The most important thing is the backtick.

This is a backtick:    `  
And when we use the ls in loop, we need double backtick:
 
   `ls`

If you don't know where the backtick button is on your keyboard, you can search the images in google.

Hiç yorum yok:

Yorum Gönder