I use the following code to write raw text to files, to update my CPU-settings. Hope this helps out!
Script:
#!/bin/sh
cat > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor <<EOF
performance
EOF
cat > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor <<EOF
performance
EOF
This writes the text "performance" to the two files mentioned in the script above. This example overwrite old data in files.
This code is saved as a file (cpu_update.sh) and to make it executable run:
chmod +x cpu_update.sh
After that, you can run the script with:
./cpu_update.sh
IF you do not want to overwrite the old data in the file, switch out
cat > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor <<EOF
with
cat >> /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor <<EOF
This will append your text to the end of the file without removing what other data already is in the file.