Thursday, 15 September 2011

bash - Why does my output redirection not write to file? -


I have the following in a file named column:

  SCHEMA_123 | User | ID SCHEMA_123 | User | Name SCHEMA_123 | User | Role  

I run the following and I am getting in the standout:

  cat column. Sed 's / / /' ji '| Sed '/ | /./g ' 

Output:

  SCHEMA_123.user.id SCHEMA_123.user.name SCHEMA_123.user.role  

I am trying to redirect the output file with the same filename (column), but the file ends empty. What I'm doing here:

  cat column | Sed 's / / /' ji '| Sed 's / | /. / G '& gt; Column  

If I use a different filename, I get the output that I see. Am I not able to read a file, modify it, and write it back in the same filename?

You can not read and write the same file because the shell command line must be executed before the output file Will be erased in zero byte. Use inline editing option in

sed :

  sed -i.bak 's / / g ; S / | /./g 'column  

No comments:

Post a Comment