Question: Hello I'm trying to do something like this but it wont work, can you guys tell me help me out?

```
/usr/bin/mysql -B -r -h ******** -u******* -p****** -D***** \
    -e'SELECT `username`, `uid`, `gid`, `homedir` FROM `some_table`)' | \
        awk '{print $1":x:"$2":"$3"::"$4":/usr/sbin/nologin"}' >> /tmp/file1 ;
        awk '{print $1":"$5":13753:0:99999:7:::"}'>>/tmp/file2

```

Changing ";" to "&&" doesn't work either.
Both file1 and file2 is created, but only file1 contains data.
So basically what I want to do is using the same variables for two commands

Answer: 
Try this:

```
/usr/bin/mysql -B -r -h ******** -u******* -p****** -D***** \
    -e'SELECT `username`, `uid`, `gid`, `homedir` FROM `some_table`)' | \
        awk '{ print $1":x:"$2":"$3"::"$4":/usr/sbin/nologin" >> "/tmp/file1"; 
               print $1":"$5":13753:0:99999:7:::" >> "/tmp/file2" }'

```
You've made quite a mess, starting with the formatting of your question (see what I've done above which should make things below more clear).

***First problem:***  

 If you have a semicolon (`;`) or a "continue-on-success (`&&`) you are running two separate sets of commands.  

Completely separate. It's like you ran one, hit enter and then ran the other.  

This means your second `awk` is looking on stdin for input, and not finding anything it's giving you no output (which is why `file2` is empty)

***Second Problem:***  

Separate instances of `awk` can't share variables. Either you want the second `awk` to chew on the output of the MySQL query, or you want it to chew on the output of the first `awk`.  

Since you've got 5 variables in your second `awk` I'm assuming the latter.

***Solution***  

Run the first half of the command list (everything up to the semicolon).  

Now run the second awk, and specify an input file (`awk '{print $1":"$5":13753:0:99999:7:::"}' /tmp/file1 >> /tmp/file2`).