The Archives

  • 10.Aug.17
    Interlacing file lines shell | fernape | (0)
    Recently I needed to mix several files into one single file. The point was that I needed to interlace the files so I had all the first lines of every file followed by all the second lines and so on. Put it simply, this is what I had: fapesteguia@fapesteguia:~/test$ cat file1 file 1 row 1 file 1 row 2 file 1 row 3 file 1 row 4 file 1 row 5 file 1 row 6 file 1 row 7 file 1 row 8 file 1 row 9 file 1 row 10 fapesteguia@fapesteguia:~/test$ cat file2 file 2 row 1 file 2 row 2 file 2 row 3 file 2 row 4 file 2 row 5 file 2 row 6 file ...
  • 15.Feb.11
    find command in Powershell shell | rafacas | (0)
    In my actual job I have a laptop with Windows 7 installed on it. The last time I used Windows on a daily basis was four years ago and it was Windows XP. The terminal (cmd.exe) was... well, that was not a real terminal neither a real shell. The first days using Windows 7 I had a problem (which I will explain it later) and while I was installing cygwin to run some commands I found Powershell. I have to admit that Windows now has a real shell and it seems pretty powerful. It can be installed in Windows XP and ...
  • 29.Jan.09
    sdf, public Unix shell access shell | pfortuny | (5)
    I have mentioned it several times before, but I have been told it deserves an entry on its own. The Super Dimension Fortress (known also as freeshell) is a public Unix system: that is a Unix system (actually Netbsd running on an Alpha-64) to which everyone (each person in the world having a network connection) can log in and which anyone can use. From its main page: Our mission is to provide remotely accessible computing facilities for the advancement of public education, cultural enrichment, scientific research and recreation. Members can interact electronically with each other regardless of their location using passive or interactive forums. Further purposes include ...
  • 23.Jan.09
    Space for shell | pfortuny | (5)
    So your friend sent you a batch of tiffs to be converted into jpg's (using ImageMagick's convert command). However your friend (who is not so geeky as you) uses spaces in filenames (which is a deadly sin), like in First photo of birthday.tiff Second photo.tiff You wanted to use a shell for loop, but the obvious $ for i in `find . -name *tiff` ; do convert "$i" "${i%tiff}jpg" ; done produces garbage (try it). This is just one of the consequences of your friend's carelessness. But there is a solution. IFS (Internal Field Separator) is a shell variable controlling what character(s) delimit a 'field' in ...
  • 08.Nov.08
    Is this a tty? shell | pfortuny | (0)
    That is a funny question to ask if you are a human (because you *should* know the answer). But it is not that dumb for a system. As a matter of fact, among the multiple tests the shell admits (man 1 test), there is a -t which serves specifically for that: $ test -t 0 returns 0 (that is, success or true in shell jargon) if the standard input (file descriptor 0) is open and is associated with a terminal. So, unless things are going pretty bad, the following $ test -t 0 && echo $? Should always print a 0. However, when a file ...
  • 05.Jul.08
    Finding who’s using which file descriptors shell | fernape | (0)
    Sometimes it is useful to know which processes are using a certain file. You could want to remove the file or move it, or change its name, but it's not a good idea if it's being read/written by someone else. Here is when fuser comes in hand. fuser shows the PID of the processes using a file descriptor passed as argument. $> fuser $HOME $> /home/n0str0m0: 1930c 2005c 2023c 2051c 2068c 2083c 2113c 2115c 2117c 2123c 2137c 2138c 2139c 2145c 2230c 2251c 2255c 2397c 2416c 2419c 2420c 2515c 2520c The two options I have used the most so far are: -m: tells you processes using a ...